20200424, 19:54  #1 
Apr 2020
2^{2}·5 Posts 
Need help pari gp
Hello, I really need help solving this problem in Pari / gp
"Among the numbers 3 (10 ^ 8) ≤n≤4 (10 ^ 8), find the number with the largest sum of divisors. If there are several such numbers, find all" 
20200424, 19:59  #2 
6809 > 6502
"""""""""""""""""""
Aug 2003
101×103 Posts
2·4,297 Posts 
Post moved to Homework Help.
This is a homework issue. What have you done so far? 
20200425, 07:13  #3 
Apr 2020
2^{2}·5 Posts 
Need help pari gp
hello, I need help with the task for Pari / gp "Among the numbers 3 (10 ^ 8) ≤n≤4 (10 ^ 8), find the number that has the greatest sum of divisors. If there are several such numbers, find all"

20200425, 07:28  #4 
Jun 2003
13×19^{2} Posts 
Use numdiv function

20200425, 07:54  #5 
Apr 2020
14_{16} Posts 
my problem is that I do not know this program. I have not been able to collect the task in this program for several days
Last fiddled with by User133 on 20200425 at 07:54 
20200425, 08:10  #6 
Apr 2020
2^{2}·5 Posts 
.
Last fiddled with by User133 on 20200425 at 08:11 
20200425, 08:13  #7 
Apr 2020
2^{2}·5 Posts 

20200425, 08:13  #8 
Romulan Interpreter
Jun 2011
Thailand
2×11×397 Posts 
This is for homework thread. It may be moved there later, as it has nothing to do with num theory.
Anyhow, we are trying to help. 1. Do you need just to know the answer? If so, you can easily find it on the web. 397837440, with the sum 1974067200 2. Do you need to learn pari functions? Or to use pari predefined functions to get the answer? If so, look at help for vecsum() and divisors() functions. s=0; for(n=3*10^8,4*10^8,z=vecsum(divisors(n)); if(s<z, s=z; print([n,s]))) will give you the answer in 35 minutes 3. Do you need to implement this by yourself? I don't see the teacher who will give a homework that requires using only one line of code, and only 2 functions. When I was in Uni, like >30 years ago, we had to sort a list (in Pascal, or C), and learn different ways to sort it, in the process (bubblesort, flagsort, quicksort, etc). One colleague presented program with one line of code only, he was calling the "sort" function in dBase (at the time) and was very upset when the professor, laughing his lungs out, marked him "failed". He even didn't understand that the requirement was not to sort a stupid, 20 items list, which could be easily sorted by pencil, but to learn the algorithms. True story! P.S. at axn: numdiv ??? gotcha! Last fiddled with by LaurV on 20200425 at 08:22 
20200425, 08:17  #9 
Apr 2020
2^{2}·5 Posts 
the teacher gave it and didn’t even explain anything. We asked him to help and explain, but he refuses. I quickly solved the problem itself, but I can’t build it in pari (I’ve been trying to figure out the program myself for 3 days but can’t do anything)
Last fiddled with by LaurV on 20200425 at 08:24 
20200425, 08:36  #10 
Romulan Interpreter
Jun 2011
Thailand
2×11×397 Posts 
Ok, first welcome to the forum.
It is a good netiquette not to quote the full precedent post (it overloads the forum, people know what you reply to, unless it is very specific, and you need to quote some paragraph, or you reply to older posts), and also not to reply immediately in 10 seconds after the post was done (this gives me time to edit my silly mistakes out of the text, and also avoids "flame wars", sometimes, if you wait 10 minutes before replying, and think to the issues, you find a better way to reply, or can solve the problem by yourself already). Now, the thread stays here, as it seems is more about Pari/GP than about homework. So, what did you do with pari, up to now? 1. Could you download it from its home site? (to be sure you don't have some trojan pretending to be pari) 2. Could you install it? (as simple as running the setup) 3. Did it install a "doc" folder, where the "user.pdf" or such, is copied? 4. Did you have a look at it? (RTFM) 5. Can you execute simple functions that return a result? (like the ones I posted) 6. Are you trying to do the algorithm about the sum of the divisors by yourself? (if so, then you may have a mistake inside, which results in an endless loop or so, go again through the algorithm and put some "print" to output intermediary values, or use "break" and debug it. There is no way that an algorithm which is correct and well implemented, will take more than 35 minutes to solve this problem. The piece of code I posted above (in spoilers) needs 5 minutes and 11 seconds in my (very slow) laptop which I currently work at. 7. What do you mean "build"? Are you trying to use libpari and "build" some C program with the method, or what? If so, try it in GP first to see if its working, THEN move to libpari to speed up or so. Start small. Please describe to us a little what you are trying to do. We have here some guys who can REALLY help you with Pari, with the math side, with the programming side, etc. Last fiddled with by LaurV on 20200425 at 08:47 
20200425, 08:40  #11  
Apr 2020
24_{8} Posts 
Quote:
n0=0; m0=1; p0=0; for(n=40,50, if(vecsum(divisors(n))>m0, m0=vecsum(divisors(n));n0=n); if(vecsum(divisors(n))==m0, p0+1); print("summa_del_chisla(", n, ")=", vecsum(divisors(n)), "; MAX summa_del_chisla(",n0, ")=", m0, " povtorov ", p0 ); ) } 

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
LLL in GP/Pari  paul0  Programming  2  20151117 13:04 
PARI vs GAP  skan  Miscellaneous Math  0  20121216 00:13 
pari  devarajkandadai  Programming  21  20120831 18:08 
64bit Pari?  CRGreathouse  Software  2  20090313 04:22 