Nifty math discovery I did.
For integer X; Sum of 1 to X = (X*(X+1)/2). (Way old news)
Sum of integers from X to N. ((N-X)+1)*(X+N)/2. Also old news).
X=3; N=39; input values, ((39-3)+1)*(39+3)/2 = 777.
So I got curious, can I do this for ANY value?
Turns out you cannot. Only non-primes.
Prime numbers correspond to integer N+(N+1), which includes the set of all odd integers.
Let's say you want to find the continuous integer series that sum up to 666 or 777 or 888.
The formula is 1+((M-(P*(P+1)/2))/P).
M=Non-prime number.
P=Factors of M
For example, 777 factors to primes {3, 7, 37}, but we need the regular factor pairs of 777 = 3*259=7*111=21*37.
Now let's feed the formula.
1+((M-(P*(P+1)/2))/P)
1+((777−(3*(3+1)/2))/3)=258
777=258+259+260 {3 integers in the series}
Feed it again.
1+((777−(7*(7+1)/2))/7)=108
777=108+109+110+111+112+113+114
Divide by 7, get 7 integers in the series.
Feed it again.
1+((777−(21*(21+1)/2))/21)=27
777=27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47
Which has 21 integers which sum to 777.
1+((777−(37*(37+1)/2))/37)=3
777=3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43
Starts with 3 has 37 integers in the series.
1+((777−(111*(111+1)/2))/111)=-48
Oh noes... Oh wait, thPost too long. Click here to view the full text.