20180225, 15:08  #1 
May 2016
2×3^{4} Posts 
Pari gp Command divisors() ?
Good evening,
I wanted to ask if the program parigp is faster to find the divisors of an even number, with the command divisors(), compared to an odd number with the command factor() or is it the same? thank you 
20180225, 15:47  #2 
"Forget I exist"
Jul 2009
Dumbassville
2^{6}·131 Posts 
These commands aren't even the same, factor only finds prime factors, divisors lists all divisors.

20180225, 15:53  #3 
"Dana Jacobsen"
Feb 2011
Bangkok, TH
3^{2}×101 Posts 
divisors is a bit slower than factor. Given the same size inputs, either one is slower (on average) on odds vs. evens. So it seem the question boils down to which one has the larger impact. Like sm88 said, the question is a bit odd and sounds like the XY Problem, but as asked:
An experiment: Code:
? s=0; forstep(n=10^11+0,10^11+3*10^6,2,s+=length(factor(n))); s time = 13,207 ms. 3000002 ? s=0; forstep(n=10^11+0,10^11+3*10^6,2,s+=length(divisors(n))); s time = 16,280 ms. 58547739 ? s=0; forstep(n=10^11+1,10^11+3*10^6,2,s+=length(factor(n))); s time = 17,275 ms. 3000000 ? s=0; forstep(n=10^11+1,10^11+3*10^6,2,s+=length(divisors(n))); s time = 18,658 ms. 20901346 Repeating this using 10^9 says factor wins  at that size the overhead of divisors vs. factors outweighs the extra time factoring. In my program, divisors first does a factor then constructs the divisors. I'm curious how Pari/GP does it. Looks like divisors_init calls absZ_factor(n) so it does the same thing, albeit in a more roundabout way (it handles more types, and might have more efficient iterators). Last fiddled with by danaj on 20180225 at 15:55 
20180225, 16:00  #4  
"Forget I exist"
Jul 2009
Dumbassville
8384_{10} Posts 
Quote:
Last fiddled with by science_man_88 on 20180225 at 16:00 

20180225, 16:25  #5  
"Dana Jacobsen"
Feb 2011
Bangkok, TH
3^{2}×101 Posts 
Quote:
Both factor and divisors operating on integers this size could be sped up 24x if it was particularly desired. 

20180225, 16:33  #6 
May 2016
2×3^{4} Posts 
Tanks for the reply SS88 and Danaj ,
my question is to verify operations with highly composite numbers. I explain very quickly: p1 * p2 = n * 20 = HCN highly composite number. 101*3 = 303 * 20 = 6060 Code:
(12:31) gp > divisors(6060) %2 = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 101, 202, 303, 404, 505, 606, 1010, 1212, 1515, 2020, 3030, 6060] 6060/60=101 An odd prime factor always corresponds to an even divisor. 6060/2020=3 An odd prime factor always corresponds to an even divisor. 
20180225, 17:08  #7  
"Forget I exist"
Jul 2009
Dumbassville
2^{6}×131 Posts 
Quote:


20180225, 17:14  #8 
May 2016
162_{10} Posts 

20180225, 17:20  #9 
"Forget I exist"
Jul 2009
Dumbassville
20C0_{16} Posts 

20180225, 17:26  #10 
May 2016
2×3^{4} Posts 
I noticed that every even number corresponds to an odd number, for example the even number 60 always corresponds to 3.
43*3=129*20=2580 2580/60=43 
20180225, 17:31  #11 
"Forget I exist"
Jul 2009
Dumbassville
20300_{8} Posts 

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Question about Mersenne divisors  paulunderwood  Miscellaneous Math  1  20160124 01:41 
Looking for fermat divisors, n=90120  firejuggler  Prime Sierpinski Project  2  20120110 17:14 
Density of Mersenne divisors  Random Poster  Math  1  20081215 01:14 
odd divisors of Mersennelike, question  stpascu  Factoring  1  20061016 16:31 
Number of divisors of n?  Citrix  Math  10  20060208 04:09 