![]() |
|
|
#2300 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
Last fiddled with by science_man_88 on 2011-09-08 at 23:53 |
|
|
|
|
|
|
#2301 | |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
Quote:
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 |
|
|
|
|
|
|
#2302 |
|
Romulan Interpreter
Jun 2011
Thailand
226778 Posts |
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 |
|
|
|
|
|
#2303 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
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)))))))) Last fiddled with by science_man_88 on 2011-09-09 at 11:46 |
|
|
|
|
|
|
#2304 |
|
Jun 2003
508710 Posts |
|
|
|
|
|
|
#2305 |
|
Dec 2010
Monticello
34038 Posts |
I'm out of practice, but getting line N out of a file is a one-liner in perl.
|
|
|
|
|
|
#2306 |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
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 |
|
|
|
|
|
#2307 |
|
Aug 2006
3×1,993 Posts |
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).
|
|
|
|
|
|
#2308 | |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
Quote:
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 |
|
|
|
|
|
|
#2309 | |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
Quote:
|
|
|
|
|
|
|
#2310 | ||
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
Quote:
Last fiddled with by science_man_88 on 2011-10-26 at 01:07 |
||
|
|
|
![]() |
| 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 |