![]() |
Algebraithm for calculating primes
[FONT="]For prime number A, there is only one value B, such that what А + В[sup]2[/sup] = С[sup]2[/sup]
В = (А-1)/2 С = (А+1)/2 А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В) С – В = 1 If the number of semiprime A = k1 * k2, then there are at least two values, such that А + В[sup]2[/sup] = С[sup]2[/sup] 1. 1) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); k1 = C-B; k2= C + B B2 = (n + trunc (sqrt (A))2 – A; n – natural number [1; +∞); C = n + trunc (sqrt (A)) 2. 2) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); С – В = 1 В = (А-1)/2 (B- maximum) С = (А+1)/2 Example, А = 21 B1 = (А-1)/2 = (21-1)/2 = 10; С = (А+1)/2 = (21+1)/2 = 11 21 + 10[sup]2[/sup] = 11[sup]2[/sup] If semiprime A, then there is at least one value В2< B1: Sqrt (21) = 4,58257.. Trunc (4,58257) = 4 B2 = (n + 4)2 – 21 for n =1 B2 = (1+4)[sup]2[/sup] – 21 = 4; B = 2; C = n+ 4 = 1 + 4 =5 A = С2 – В2 = (С-В)*(С+В) = (5 – 2)*(5+2) = 3*7 А=k1 * k2= 3*7[/FONT] |
[URL="http://rosettacode.org/wiki/AKS_test_for_primes#ALGOL_68"]Another algorithm for calculating primes[/URL]
|
For even more awesomeness you could use [URL="http://rosettacode.org/wiki/Miller-Rabin_primality_test#Deterministic_version"]Deterministic M-R[/URL] with ceil(n/4) as the limit.
[SIZE=1](I really wish the previously referenced task could be renamed, as far too many people think what is described is actually AKS) Tempted to post the primality regex... [/SIZE] |
[QUOTE=irina;405658][FONT="]For prime number A, there is only one value B, such that what А + В[sup]2[/sup] = С[sup]2[/sup]
В = (А-1)/2 С = (А+1)/2 А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В) С – В = 1 If the number of semiprime A = k1 * k2, then there are at least two values, such that А + В[sup]2[/sup] = С[sup]2[/sup] 1. 1) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); k1 = C-B; k2= C + B B2 = (n + trunc (sqrt (A))2 – A; n – natural number [1; +∞); C = n + trunc (sqrt (A)) 2. 2) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); С – В = 1 В = (А-1)/2 (B- maximum) С = (А+1)/2 Example, А = 21 B1 = (А-1)/2 = (21-1)/2 = 10; С = (А+1)/2 = (21+1)/2 = 11 21 + 10[sup]2[/sup] = 11[sup]2[/sup] If semiprime A, then there is at least one value В2< B1: Sqrt (21) = 4,58257.. Trunc (4,58257) = 4 B2 = (n + 4)2 – 21 for n =1 B2 = (1+4)[sup]2[/sup] – 21 = 4; B = 2; C = n+ 4 = 1 + 4 =5 A = С2 – В2 = (С-В)*(С+В) = (5 – 2)*(5+2) = 3*7 А=k1 * k2= 3*7[/FONT][/QUOTE] This is nothing but trivial algebra. Where is the ALGORITHM? You have failed to specify any kind of procedure. All you have done is assert the existence of some values satisfying some relations. |
[QUOTE=R.D. Silverman;405786]This is nothing but trivial algebra. Where is the ALGORITHM?[/QUOTE]Algebraithm for calculating primes?
|
[QUOTE=irina;405658][FONT="]For prime number A, there is only one value B, such that what А + В[sup]2[/sup] = С[sup]2[/sup]
В = (А-1)/2 С = (А+1)/2 А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В) С – В = 1 If the number of semiprime A = k1 * k2, then there are at least two values, such that А + В[sup]2[/sup] = С[sup]2[/sup] 1. 1) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); k1 = C-B; k2= C + B B2 = (n + trunc (sqrt (A))2 – A; n – natural number [1; +∞); C = n + trunc (sqrt (A)) 2. 2) А = С[sup]2[/sup] – В[sup]2[/sup] = (С-В)*(С+В); С – В = 1 В = (А-1)/2 (B- maximum) С = (А+1)/2 Example, А = 21 B1 = (А-1)/2 = (21-1)/2 = 10; С = (А+1)/2 = (21+1)/2 = 11 21 + 10[sup]2[/sup] = 11[sup]2[/sup] If semiprime A, then there is at least one value В2< B1: Sqrt (21) = 4,58257.. Trunc (4,58257) = 4 B2 = (n + 4)2 – 21 for n =1 B2 = (1+4)[sup]2[/sup] – 21 = 4; B = 2; C = n+ 4 = 1 + 4 =5 A = С2 – В2 = (С-В)*(С+В) = (5 – 2)*(5+2) = 3*7 А=k1 * k2= 3*7[/FONT][/QUOTE] It appears that you suggest to select n=1, 2, 3, ... until you get the factorization. This is just [URL="https://en.wikipedia.org/wiki/Fermat%27s_factorization_method"]Fermat's method[/URL]. |
Mersenne prime number search algorithm
?
|
| All times are UTC. The time now is 10:44. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.