mersenneforum.org  

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

Reply
 
Thread Tools
Old 2011-09-08, 23:47   #2300
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
a few codes I've sent through PM:

Code:
ali(n)=a=n-1;b=[];for(x=0,floor(.5*a),if(x==0,if(sigma(a^2)-a^2==n,b=concat(b,a^2)),if(sigma((x)*(a-x))-((x)*(a-x))==n,b=concat(b,(x)*(a-x)))));b=vecsort(b,,8)
checks up to floor(.5*a) in matching pairs multiplying them together and if the sigma checks go through puts them into b. sorts the vector at the end.


Code:
for(z=6,6,print(z);for(x=1,#ali(z),print("\t"ali(z)[x]);for(y=1,#ali(ali(z)[x]),print("\t\t"ali(ali(z)[x])[y]);for(h=1,#ali(ali(z)[x])[y],print("\t\t\t"ali(ali(ali(z)[x])[y])[h]);for(i=1,#ali(ali(ali(z)[x])[y])[h],print("\t\t\t\t"ali(ali(ali(ali(z)[x])[y])[h])[i]))))))
z can be changed to any group of consecutive numbers this basically does the previous one on top of each other forming generation in later talk I believe I talk of it as aligen(n), please note these codes only find ones that have (n-1) split into 2 divisors.

the attachment has been scanned since I want to double check it, it represents most that I have tried with these codes.
does anyone else know the way to extend the first code to check for 3 values to multiply that add up to a? I get the sigma check change would be something like: sigma(<new variable>*x*(a-(x+<new variable>)))==n but I want it to act correct so it checks sums of 2 numbers first then three.

Last fiddled with by science_man_88 on 2011-09-08 at 23:53
science_man_88 is offline   Reply With Quote
Old 2011-09-09, 02:08   #2301
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
does anyone else know the way to extend the first code to check for 3 values to multiply that add up to a? I get the sigma check change would be something like: sigma(<new variable>*x*(a-(x+<new variable>)))==n but I want it to act correct so it checks sums of 2 numbers first then three.
wasteful ( doesn't solve for 2 as well because if so it throws 0 into sigma) method found!

Code:
(n)->a=n-1;for(x=1,a,for(y=1,a,for(z=1,a,if(1+x+y+z==a&&sigma(x*y)-(x*y)==n,print(x*y),if(1+x+y+z==a&&sigma(x*z)-(x*z)==n,print(x*z),if(1+x+y+z==a&&sigma(y*z)-(y*z)==n,print(y*z),if(1+x+y+z==a&&sigma(x*y*z)-(x*y*z)==n,print(x*y*z))))))))

Last fiddled with by science_man_88 on 2011-09-09 at 02:11
science_man_88 is offline   Reply With Quote
Old 2011-09-09, 05:41   #2302
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

226778 Posts
Default Asking the pari experts....

Question 1:
I have a file with a million lines. (So what?)
ASCII.
Each line is a number (no other characters except 0..9)
I have (in a separate variable) the number k. (not your business where did I get it from)

I want to read in a variable the number on the line k on the file.

How the hell I do that in pari/gp???

There is no "seek", "readline" or equivalents. The only possibility I found is to read all the file in a vector with "readvec" and take the component I need. What it would take (beside of "ages") few wheelbarrows of memory.

Question 2:
How the hell I can take the class "c" in "x=Mod(c,m)" as integer? Beside of the "ugly" construction "component(x,2)", which took me 2 days to find it (no specs in the help). They provide the member function ".mod" to take the m (like x.mod will return m), but no function to take the c. I figured later that I can apply a "component()" function to any internal structure, and from that it did not take me long to find out the the class c is in fact... the second component of the structure (the Mod structure is stored internally "viceversa").

In spite of the fact this question looks somehow tendentious, or picky, the reason is the fact that the only way to do a (somehow fast) "modexp" in pari is "a=Mod(x,m)^y" (which is taking modular reduction at each step, that is why is just "somehow" fast, and not really fast as in yafu), and latter if I want to compare "a==b" this will promote b from t_INT into t_INTMOD, killing all the process further. That is why the "component()" step has to be added.

Any idea? (Question 1 is really important, otherwise I have to write a separate application, and use "extern()" to read the line and put it in a separate file, and feed that to pari. Question 2 is just a curiosity.)

Thanks in advance.

Last fiddled with by LaurV on 2011-09-09 at 05:49
LaurV is offline   Reply With Quote
Old 2011-09-09, 11:44   #2303
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
wasteful ( doesn't solve for 2 as well because if so it throws 0 into sigma) method found!

Code:
(n)->a=n-1;for(x=1,a,for(y=1,a,for(z=1,a,if(1+x+y+z==a&&sigma(x*y)-(x*y)==n,print(x*y),if(1+x+y+z==a&&sigma(x*z)-(x*z)==n,print(x*z),if(1+x+y+z==a&&sigma(y*z)-(y*z)==n,print(y*z),if(1+x+y+z==a&&sigma(x*y*z)-(x*y*z)==n,print(x*y*z))))))))
few changes got it working for both 2 and 3 number combinations:

Code:
a=n-1;for(x=0,a,for(y=1,a,for(z=1,a,if(x+y+z==a&&x!=0&&sigma(x*y)-(x*y)==n,print(x*y),if(x+y+z==a&&x!=0&&sigma(x*z)-(x*z)==n,print(x*z),if(x+y+z==a&&sigma(y*z)-(y*z)==n,print(y*z),if(x+y+z==a&&x!=0&&sigma(x*y*z)-(x*y*z)==n,print(x*y*z))))))))
okay testing proves I stupidly forgot to print a^2 ( later will turn to a concat) and use a vecsort at the end.

Last fiddled with by science_man_88 on 2011-09-09 at 11:46
science_man_88 is offline   Reply With Quote
Old 2011-09-09, 12:58   #2304
axn
 
axn's Avatar
 
Jun 2003

508710 Posts
Default

Quote:
Originally Posted by LaurV View Post
Question 2:
How the hell I can take the class "c" in "x=Mod(c,m)" as integer?
Look at lift() and centerlift()
axn is offline   Reply With Quote
Old 2011-09-09, 18:17   #2305
Christenson
 
Christenson's Avatar
 
Dec 2010
Monticello

34038 Posts
Default

I'm out of practice, but getting line N out of a file is a one-liner in perl.
Christenson is offline   Reply With Quote
Old 2011-10-23, 23:07   #2306
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Pardon the question.. but similar to how (4!+1) = 5^2; (5!+1) = 11^2; (7!+1) = 71^2.. are there any examples of (n!+1) = x^3 (where n and x are integers)

Last fiddled with by 3.14159 on 2011-10-23 at 23:16
3.14159 is offline   Reply With Quote
Old 2011-10-23, 23:37   #2307
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Pardon the question.. but similar to how (4!+1) = 5^2; (5!+1) = 11^2; (7!+1) = 71^2.. are there any examples of (n!+1) = x^3 (where n and x are integers)
Doubtful, since x would have to be divisible by only cubes of large primes which are very rare (sum converges). Just to be divisible by one prime cube where the prime is over 10,000 is a one-in-two billion chance, and most of that is on the lower end (which doesn't take care of the bulk of the number).
CRGreathouse is offline   Reply With Quote
Old 2011-10-24, 03:28   #2308
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Doubtful, since x would have to be divisible by only cubes of large primes which are very rare (sum converges). Just to be divisible by one prime cube where the prime is over 10,000 is a one-in-two billion chance, and most of that is on the lower end (which doesn't take care of the bulk of the number).
Ah, cool. Thanks for the heads-up.

So would it be safe to say that (n!+1) = x^y has no solutions when y > 2?
(n, x, and y all being integers, of course.)

Lastly, reading through this thread.. can't help but feel a slight bit of embarrassment at what I've posted so far.

Last fiddled with by 3.14159 on 2011-10-24 at 03:29
3.14159 is offline   Reply With Quote
Old 2011-10-26, 00:49   #2309
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default making a new variable name via script ?

Quote:
(x,y)->eval(Str(x))==y
the problem is when I retyped the name with a question mark it worked, But the flaw was copying in the name or other ways of getting the value behind the variable like typing it's name don't seem to work on my end.
science_man_88 is offline   Reply With Quote
Old 2011-10-26, 00:58   #2310
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
the problem is when I retyped the name with a question mark it worked, But the flaw was copying in the name or other ways of getting the value behind the variable like typing it's name don't seem to work on my end.
from a fresh window of gp.exe:

Quote:
(21:55)>var(x,y) = eval(Str(x))==return(y)
%1 = (x,y)->eval(Str(x))==return(y)
(21:55)>?weekend
weekend: unknown identifier

(21:55)>var(weekend,5)
%2 = 5
(21:55)>?weekend
weekend: user defined variable

(21:56)>weekend
%3 = weekend
okay so retyping the equality with one equal sign can add the value after creation

Last fiddled with by science_man_88 on 2011-10-26 at 01:07
science_man_88 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

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


Fri Aug 6 15:31:41 UTC 2021 up 14 days, 10 hrs, 1 user, load averages: 2.36, 2.72, 2.83

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, 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.