mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2020-04-24, 19:54   #1
User133
 
Apr 2020

22·5 Posts
Unhappy 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"
User133 is offline   Reply With Quote
Old 2020-04-24, 19:59   #2
Uncwilly
6809 > 6502
 
Uncwilly's Avatar
 
"""""""""""""""""""
Aug 2003
101×103 Posts

47×233 Posts
Default

Post moved to Homework Help.

This is a homework issue. What have you done so far?
Uncwilly is online now   Reply With Quote
Old 2020-04-25, 07:13   #3
User133
 
Apr 2020

22×5 Posts
Default 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"
User133 is offline   Reply With Quote
Old 2020-04-25, 07:28   #4
axn
 
axn's Avatar
 
Jun 2003

154616 Posts
Default

Use numdiv function
axn is offline   Reply With Quote
Old 2020-04-25, 07:54   #5
User133
 
Apr 2020

22·5 Posts
Default

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
User133 is offline   Reply With Quote
Old 2020-04-25, 08:10   #6
User133
 
Apr 2020

2010 Posts
Default

.

Last fiddled with by User133 on 2020-04-25 at 08:11
User133 is offline   Reply With Quote
Old 2020-04-25, 08:13   #7
User133
 
Apr 2020

22·5 Posts
Default

Quote:
Originally Posted by axn View Post
Use numdiv function
I don’t even know the structure of building, I work for the first time in my life. You can more details please
User133 is offline   Reply With Quote
Old 2020-04-25, 08:13   #8
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
"name field"
Jun 2011
Thailand

5×112×17 Posts
Default

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 ??? gotcha!

Last fiddled with by LaurV on 2020-04-25 at 08:22
LaurV is offline   Reply With Quote
Old 2020-04-25, 08:17   #9
User133
 
Apr 2020

22×5 Posts
Default

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
User133 is offline   Reply With Quote
Old 2020-04-25, 08:36   #10
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
"name field"
Jun 2011
Thailand

5·112·17 Posts
Default

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
LaurV is offline   Reply With Quote
Old 2020-04-25, 08:40   #11
User133
 
Apr 2020

248 Posts
Default

Quote:
Originally Posted by Uncwilly View Post
Post moved to Homework Help.

This is a homework issue. What have you done so far?
{
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 );
)
}
User133 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
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

All times are UTC. The time now is 15:38.


Wed Mar 29 15:38:05 UTC 2023 up 223 days, 13:06, 0 users, load averages: 1.64, 1.19, 1.06

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔