![]() |
|
|
#1717 |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
the important part is this:
Code:
1. Determine the integer square root of N.
sqrN = Int(Sqr(n))
2. Determine the square of Step 1.
sqrN2 = sqrN * sqrN
(Note that sqrN2 is initially the greatest perfect square less than N.)
3. Determine the integer square root of Step 2 minus N.
PCS = Int(Sqr(Abs(sqrN2 - n)))
(Let's say PCS means 'perfected counting square'.)
4. Determine if the sum of Step 2 and Step 3 is a factor of N.
If mod(n, PCS + sqrN) = 0 then we have a factor, and we're done.
(Similarly, PCS minus sqrN would produce the same result.)
5. If not, add 1 to Step 1 (that is, sqrN+1) and repeat.
I think you can start with a for loop setting the minimum to floor(sqrt(n)) and looping until the number if needed (don't worry there will be a break command). sqrN2 = sqrN * sqrN then set this up as another variable just in the loop( it depends on the loop variable). PCS = Int(Sqr(Abs(sqrN2 - n))) also set in the loop(in th order shown, replacing Int() with floor()). Make and if statement(in the loop) to check the modulus. If it is false do nothing if it is 0 break(1) ( however best practice I think is to use the reverse jmp of asm so may have to reverse something). |
|
|
|
|
|
#1718 | |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Quote:
1. sqrtint(n). 2. (sqrtint(n))^2. 3. n - (sqrtint(n))^2. 4. (sqrtint(n))^2 + (n -(sqrtint(n))^2) mod n. 5. If (sqrtint(n))^2 + (n -(sqrtint(n))^2) mod n = 0, factors found. 6. If (sqrtint(n))^2 + (n -(sqrtint(n))^2) mod n !=0, repeat steps 1-5 until factors are found. Last fiddled with by 3.14159 on 2010-11-27 at 18:51 |
|
|
|
|
|
|
#1719 |
|
"Forget I exist"
Jul 2009
Dumbassville
20C016 Posts |
I understand it as:
Code:
test(n)=for(sqrN=floor(sqrt(n)),n,sqrN2=sqrn^2;PCS=floor(sqrt(abs(sqrN2-n)));if(Mod(sqrN2+PCS,n)!=0,,break())) Code:
*** floor: incorrect type in gfloor. |
|
|
|
|
|
#1720 | |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Quote:
Since they call it "Improved squares", I'll title it, "impsqs". I'll have to follow the six steps. Last fiddled with by 3.14159 on 2010-11-27 at 18:56 |
|
|
|
|
|
|
#1721 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
test(n)=for(sqrN=sqrtint(n),n,sqrN2=sqrN^2;PCS=sqrtint(sqrN2-n);if(Mod(sqrN2+PCS,n)!=0,,break())) Code:
*** sqrtint: negative integer in sqrtint. |
|
|
|
|
|
#1722 |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Take a closer look at the script. There's a mistake there, and it might be right under your nose.
|
|
|
|
|
|
#1723 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
oh reversed the modulo dah lol. Last fiddled with by science_man_88 on 2010-11-27 at 19:05 |
|
|
|
|
|
|
#1724 |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Here's how to do it without using a script, in PARI/GP;
Code:
(14:03) gp > 3926696294764459 %203 = 3926696294764459 (14:03) gp > sqrtint(%) %204 = 62663356 (14:03) gp > %204^2 %205 = 3926696185182736 (14:03) gp > %203-%205 %206 = 109581723 (14:04) gp > Mod(%203, %206 + %204) %207 = Mod(81019925, 172245079) Last fiddled with by 3.14159 on 2010-11-27 at 19:09 |
|
|
|
|
|
#1725 | ||
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
Quote:
Last fiddled with by science_man_88 on 2010-11-27 at 19:10 |
||
|
|
|
|
|
#1726 | |
|
May 2010
Prime hunting commission.
24·3·5·7 Posts |
Quote:
Therefore, there are no negative numbers involved. Perhaps you can develop a script from that piece of information. Last fiddled with by 3.14159 on 2010-11-27 at 19:14 |
|
|
|
|
|
|
#1727 |
|
"Forget I exist"
Jul 2009
Dumbassville
20C016 Posts |
I've only got one factor properly, for the number they originally give the example with. The the other factor became 37 though.
|
|
|
|
![]() |
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 |