I need to create a C code for a sum of square of four consecutive primes, for an input number between 0 and 10ˆ8. However, i can't find a general formula to do this.
For example: the user input for 87 and 204, the program returns the sum of squares of four consecutive primes as result.
87 = 2ˆ2 + 3ˆ2 + 5ˆ2 + 7ˆ2
204 = 3ˆ2 + 5ˆ2 + 7ˆ2 + 11ˆ2
If the number couldn't be written as a sum of squares of four consecutive primes, the program may return a message saying isn't possible. Any help is appreciated. Thanks!!
A very naive way would be to use the sieve of eratosthenes (I think its called that way) to enumerate all primes up to $\sqrt{\text{input}/2}$ and check any four consecutive primes if their sum of squares matches the input...