%I #5 Sep 20 2020 00:01:55
%S 2,2,3,4,7,6,7,9,9,10,13,12,19,16,15,16,31,20,19,22,21,22,25,24,40,28,
%T 27,34,31,30,31,33,35,34,37,36,37,52,41,40,43,42,169,46,45,52,61,50,
%U 49,52,51,52,55,54,55,58,57,184,70,69,67,67,65,64,67,66,73,70,69,70,442
%N Least m > n such that n + ... + m = p*2^k with p prime and k >= 0.
%C Numbers of the form p*2^k (A038550) are the integers having a unique representation as sum of two or more consecutive positive integers, n + ... + m with m > n > 0.
%C This function is useful for computing A336897 in an efficient way
%F a(n) = min {p - n, q + n - 1}, where p = 2^r + 2n - 1 and q = 2^s - 2n + 1 are the smallest primes of the respective form.
%e 0 + 1 = 1 is not of the required form, but 0 + 1 + 2 = 3 is, so a(0) = 2.
%e For n = 1, n + 2 = 3 is of the required form, hence a(1) = 2.
%e For n = 2, n + 3 = 5 is of the required form, hence a(2) = 3.
%e For n = 3, n + 4 = 7 is of the required form, hence a(3) = 4.
%e For n = 4, 4 + 5 = 9 and 4 + 5 + 6 = 15 are not of the required form, but 4 + 5 + 6 + 7 = 22 = 11*2 is, hence a(4) = 7.
%o (PARI) apply( A332106(n)={my(r=1, p=2*(r+n)-1, s=2<<exponent(n+!n), q=2*(s-n)+1); while(n, if(p-n<q+n-1, isprime(p)&&return(p-n); p+=r*=2, isprime(q)&&return(q+n-1); q+=s*=2));2} , [0..77])
%Y Cf. A038550, A336897.
%K nonn
%O 0,1
%A _M. F. Hasler_, Aug 29 2020