![]() |
[QUOTE=3.14159;238919]Sure.[/QUOTE]
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.[/CODE] 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). |
[QUOTE=science_man_88;238921]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.[/CODE] 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).[/QUOTE] Without all their fluffy language, I understand it as: 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. |
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] but Pari tells me: [CODE] *** floor: incorrect type in gfloor.[/CODE] |
[QUOTE=science_man_88;238924]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] but Pari tells me: [CODE] *** floor: incorrect type in gfloor.[/CODE][/QUOTE] Just use sqrtint(n), and n. There's no need to toss in unnecessary variables. Since they call it "Improved squares", I'll title it, "impsqs". I'll have to follow the six steps. |
[CODE]test(n)=for(sqrN=sqrtint(n),n,sqrN2=sqrN^2;PCS=sqrtint(sqrN2-n);if(Mod(sqrN2+PCS,n)!=0,,break()))[/CODE]
now I get: [CODE]*** sqrtint: negative integer in sqrtint.[/CODE] |
[QUOTE=science_man_88;238927][CODE]test(n)=for(sqrN=sqrtint(n),n,sqrN2=sqrN^2;PCS=sqrtint(sqrN2-n);if(Mod(sqrN2+PCS,n)!=0,,break()))[/CODE]
now I get: [CODE]*** sqrtint: negative integer in sqrtint.[/CODE][/QUOTE] Take a closer look at the script. There's a mistake there, and it might be right under your nose. |
[QUOTE=3.14159;238928]Take a closer look at the script. There's a mistake there, and it might be right under your nose.[/QUOTE]
I don't see it. they have PCS= sqrtint(sqrN2-n). oh reversed the modulo dah lol. |
[QUOTE=science_man_88;238929]I don't see it. they have PCS= sqrtint(sqrN2-n).[/QUOTE]
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)[/CODE] Okay, I just realized that was incorrect. |
[QUOTE=3.14159;238930]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)[/CODE][/QUOTE] Yeah they point out subtraction should work must of confused me lol. [QUOTE]Int(Sqr(Abs(sqrN2 - n)))[/QUOTE] |
[QUOTE=science_man_88;238931]Yeah they point out subtraction should work must of confused me lol.[/QUOTE]
The "Abs", means, "The absolute value of". Therefore, there are no negative numbers involved. Perhaps you can develop a script from that piece of information. |
I've only got one factor properly, for the number they originally give the example with. The the other factor became 37 though.
|
| All times are UTC. The time now is 23:12. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.