![]() |
Reverse process sum of odd numbers from x to y. What is the fastest method?
If I know the sum S of odd numbers from x to y
[(y+1)/2]^2-[(x-1)/2]^2=S What is the computationally fastest way to know x and y by excluding x = y? Example [(y+1)/2]^2-[(x-1)/2]^2=249 thank you |
[QUOTE=Alberico Lepore;466517]If I know the sum S of odd numbers from x to y
[(y+1)/2]^2-[(x-1)/2]^2=S What is the computationally fastest way to know x and y by excluding x = y? Example [(y+1)/2]^2-[(x-1)/2]^2=249 thank you[/QUOTE] depends, do you assume only one set of values works ? 9 for example, is the difference of 16 and 25, it's also the difference between 0 and 9 . 25, is the difference of 0 and 25, and it's also the difference between 144 and 169. |
1 Attachment(s)
Please see the attached screenshot from Wolfram Alpha.
|
[QUOTE=Alberico Lepore;466517]If I know the sum S of odd numbers from x to y
[(y+1)/2]^2-[(x-1)/2]^2=S What is the computationally fastest way to know x and y by excluding x = y? Example [(y+1)/2]^2-[(x-1)/2]^2=249 thank you[/QUOTE] Let a=(y+1)/2 and b=(x-1)/2. Then you have a^2 - b^2 = S, or, apparently, (a-b)(a+b)=S. So: you factor your S and for each divisor pair, you can determine a and b. For example for S=249, you have a-b=1, a+b=249 or a-b=3, a+b=83. |
[b]Batalov[/b] has already given the essentials: x and y are determined from integer factorizations of S. I mention a few nit-picking details.
Formulaically, [(y+1)/2]^2-[(x-1)/2]^2 is invariant under the substitutions y <-- -y - 2 and x <-- -x + 2. The former does not fit the original "sum of odd numbers from x to y" description in which we are apparently assuming x and y are odd, 0 < x < y. However, the x-substitution does work; it merely prepends canceling negative and positive terms to the original sum when x > 1. If x = y, the substitution gives the pair (-y + 2, y); if y > 1, then x = -y + 2 is not equal to y. So if S > 1 is odd, the formula (-S + 2, S) is probably the computationally fastest solution with x <> y, consistent with the "sum of consecutive odd numbers" description. If S is an odd prime, this is the [i]only[/i] such solution. For even values of S, the problem can only have solutions when S is divisible by 4. In this case, the solutions are again as [b]Batalov[/b] described, except one uses factorizations of S in which both factors are even. |
[QUOTE=Dr Sardonicus;466578][b]Batalov[/b] has already given the essentials: x and y are determined from integer factorizations of S.[/QUOTE]Did no-one else spot the likelihood that the OP was playing around with factorization algorithms?
The example, showing a difference of squares (the basis of many factoring algorithms since Fermat) was the giveaway for me. |
Thanks for the answers.
Adding 620677=p^2+6*(y+1)*p 629641=[p+6*(y-x+2)/2]^2+6*(x-1)*[p+6*(y-x+2)/2] There are other ways ? For fairness I tell you what this is for [url]https://www.academia.edu/34339494/Fattorizzazione_RSA_di_Lepore_Complessit%C3%A0_random[/url] |
I found a solution
But I do not have the means to test it Wolfram does not allow me to do that Kindly you could test (6*(103446-6*a^2-2*a)/(6*a+1)+((6*a+1)^2-(6*(a-1)+1)^2)/6)=(6*(104940-6*b^2-2*b)/(6*b+1)+((6*b+1)^2-(6*(b-1)+1)^2)/6) , a+(y-x+2)/2+2*sqrt[(9*a^4+6*a^3-319301*a^2-106434*a+2675268480)/(6*a+1)^2]=b , 620677=(6*a+1)^2+6*(y+1)*(6*a+1) , 629641=(6*b+1)^2-6*(x-1)*(6*b+1) thank you |
If you solve the problem (sum of odd numbers of odd number items) you solve the problem of factorization and therefore of primality
look at this I write in Italian as I can not explain it in English Considerazioni di Lepore su Primalità e Fattorizzazione Definizione 1 Ogni numero dispari, non primo, non divisibile per due e per tre si scrive come somma di numeri dispari consecutivi positivi. Dimostrazione Sia N un numero non divisibile per due e per tre allora N=p*q=q*(p-1+1)=(2*p-2)*q/2+q=(y+x)*(y-x)/4+(y+x)/2=((y+1)/2)^2-((x-1)/2)^2 Definizione 2 Ogni numero fattorizzabile N=p*q si scrive come somma di numeri dispari consecutivi positivi da p+q-1 a (q-p)+1 Dimostrazione N=((y+1)/2)^2-((x-1)/2)^2=((p+q-1+1)/2)^2-(((q-p)+1 -1)/2)^2=p*q Definizione 3 Ogni numero primo P non si scrive come somma di numeri dispari consecutivi positivi. Dimostrazione Dalla definizione 2 e dalla definizione di numero primo si ha che p=1 e q=P quindi si ha p+q-1=P e (q-p)+1=P quindi si scrive soltanto come se stesso. Alberico Lepore 4 Settembre 2017 |
1 Attachment(s)
[COLOR=LemonChiffon].[/COLOR]
|
[QUOTE=Batalov;467079][COLOR=LemonChiffon].[/COLOR][/QUOTE]
You can calculate the distribution of the prime numbers and consequently the primality of a number |
| All times are UTC. The time now is 23:27. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.