Since you mentioned TakeWhile and FoldWhile, let me first give you a one-line with NestWhile:
NestWhile[With[{c=First[#]+1,s=Last[#]},{c,s+Prime[c]^2}]&,{1,1},#[[2]]<10^10&]
(* {823, 10025552438} *)
What follows is my original answer that shows binary search which is not the most appropriate thing in this situation but still very fast.
Consider the vector {a,b,c} and note that the dot-product of it with itself is a^2+b^2+c^2. This naturally leads to a simple function that calculates your sum of prime squares:
f[n_] := #.# &[Prime[Range[n]]]
A quick check shows that an upper bound is n=1000. Now, implement a quick binary search which will converge fast:
search[_, _, lo_, hi_] := {lo + 1, Prime[lo + 1]} /; hi - lo <= 1;
search[f_, goal_, lo_, hi_] := With[{cent = Round[(hi + lo)/2]},
If[f[cent] > goal,
search[f, goal, lo, cent],
search[f, goal, cent, hi]
]
]
It starts with a lower and upper bound and always divides this range.
search[f, 10^10, 10, 1000] // AbsoluteTiming
(* {0.00287, {823, 6323}} *)
So the answer is $2^2+3^2\ldots+p_{823}^2$. Note, that I violated your definition since I'm only summing real primes and don't include the 1. The answer is still correct though :)
Quick check
f[823]
(* 10025552442 *)
and
f[822]
(* 9985572113 *)
seems correct. You should note that it only took exactly 10 steps. You can show this by introducing a step-variable that is incremented.
int[k_?NumberQ] := NIntegrate[n^2*(Log[n] + Log[Log[n]] - 1)^2, {n, 1, k}] FindRoot[int[k] == 10^10, {k, 100}]. – Daniel Lichtblau Feb 26 '18 at 16:41