![]() |
![]() |
#1 |
Apr 2020
22·5 Posts |
![]()
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" |
![]() |
![]() |
![]() |
#2 |
6809 > 6502
"""""""""""""""""""
Aug 2003
101×103 Posts
47×233 Posts |
![]()
Post moved to Homework Help.
This is a homework issue. What have you done so far? |
![]() |
![]() |
![]() |
#3 |
Apr 2020
22×5 Posts |
![]()
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"
|
![]() |
![]() |
![]() |
#4 |
Jun 2003
154616 Posts |
![]()
Use numdiv function
|
![]() |
![]() |
![]() |
#5 |
Apr 2020
22·5 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 2020-04-25 at 07:54 |
![]() |
![]() |
![]() |
#6 |
Apr 2020
2010 Posts |
![]()
.
Last fiddled with by User133 on 2020-04-25 at 08:11 |
![]() |
![]() |
![]() |
#7 |
Apr 2020
22·5 Posts |
![]() |
![]() |
![]() |
![]() |
#8 |
Romulan Interpreter
"name field"
Jun 2011
Thailand
5×112×17 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 3-5 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 ??? ![]() ![]() Last fiddled with by LaurV on 2020-04-25 at 08:22 |
![]() |
![]() |
![]() |
#9 |
Apr 2020
22×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 2020-04-25 at 08:24 |
![]() |
![]() |
![]() |
#10 |
Romulan Interpreter
"name field"
Jun 2011
Thailand
5·112·17 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 3-5 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 2020-04-25 at 08:47 |
![]() |
![]() |
![]() |
#11 | |
Apr 2020
248 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 | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
LLL in GP/Pari | paul0 | Programming | 2 | 2015-11-17 13:04 |
PARI vs GAP | skan | Miscellaneous Math | 0 | 2012-12-16 00:13 |
pari | devarajkandadai | Programming | 21 | 2012-08-31 18:08 |
64-bit Pari? | CRGreathouse | Software | 2 | 2009-03-13 04:22 |