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, the 111 integers cancel each other out to zeroes. Easy trick, if you get negative results, FLIP THE SIGN THEN ADD +1. So -48 becomes 48 then +1=49.
Your next integer series begins at 49, and (111-49=62) so the series ends at 62.
777=49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62
And so on...
Note that no prime can be the sum of N+(N+1)+(N+2)+... (N+X), only the N+(N+1) value which includes all odd integers. A self-evident factor occurs because N+(N+2)+(N+3) is always divisible by 3. For 4 continuous integer series values, they likewise are divisible by 4 and so on. Ergo, no prime has divisors except itself and 1, so no N+(N+1)+(N+2)+... (N+X) integer summation series can sum to any prime number because it would be divisible evenly by some other number.