I've been struggling with this for over a month now. The coding challenge on HR is similar to the official Project Euler 233, but instead of finding $f(N)=420$, your code may need to solve for $f(N)=12$. Also, instead of the result being the sum of the $n$'s, it is just the count of the $n$'s.
Following is the official challenge:
Let $f(n)$ be the number of points with integer coordinates that are on a circle passing through $(0,0)$, $(0,n)$, $(n,0)$ and $(n,n)$.
It can be shown that $f(10000)=36$.
Given two integers $N$ and $m$, what is the number of all positive integers $n \le N$ such that $f(n)=4m$?
So, I must be going about this the wrong way, and that is basically what the HR community told me, but I really do not see any other way to generate the correct solution.
To use one of the smallest examples I can think of, if $N=13$... then we know that:
$f(5) = 12$, $f(10) = 12$, and $f(13) = 12$, so the answer would be $3$.
I can see that $f(n) = 12$ when the number has one and only one prime of the form $4k+1$.
So my approach would generally involve producing all primes $4k+1 \le N$ in order to determine the answer. But the problem with that approach is that when $f(n)=12$, $N$ can be as large as $5 \times 10^{10}$. That is far too many primes to generate for the code to run in under a couple seconds.
I can only imagine that there must be some way to come up with the answer $3$ if you know that $N=13$ without generating all primes $\le 13$, but I am really clueless.
I guess my actual question would be that: "Is there a way to find the solution without knowing all primes $\le N$ or would you, in fact, need all primes $\le N$ to solve for $f(n)=12$?"
If the answer to that question is "Yes, there is a way to find the solution without knowing all primes $\le N$", then my next question would be "can you offer some clues and/or point me to online material I can research that could help me recognize this solution?"
Thanks in advance!
I found a PDF, "COUNTING PRIMES IN RESIDUE CLASSES" , which shows what appears to be a fast way to count the number of primes congruent to $l$ modulo $k$ up to $x$.
So I guess I'm saying this is kind of an answer (but I still have questions)
The equations are quite complex and I have not yet translated them into layman programmer terms in order to produce a C (my language of choice) algorithm.
I think what I really need is a person who speaks both "math" and "code" to translate this math for me, and then I can implement the algorithm and use it to solve the overall challenge.
I think I might understand $P_2(x,y,l)$ but I am unsure about a few elements in the following sections:
Then the function $P_2(x,y,l)$ is later reduced to:
Following are some of what I'm confused about:
My best code translation of these summation formulas (which is very incomplete atm) is: