OFFSET
1,2
LINKS
Jason Kimberley, Table of n, a(n) for n = 1..100000
MATHEMATICA
Map[1 + Length@ TakeWhile[Differences@ #, # < 0 &] &, #] &@ Table[# Floor[n Sqrt[2/#]]^2 &@ Prime@ k, {n, 105}, {k, PrimePi[2 n^2]}] (* Michael De Vlieger, Feb 17 2017 *)
PROG
(Magma)
A:=func<n, k|Isqrt(2*n^2 div k)^2*k>;
select j else #P) where P is PrimesUpTo(2*n^2)>;
[A278116(n):n in[1..103]];
(Python)
def isqrt(n):
if n < 0:
raise ValueError('imaginary')
if n == 0:
return 0
a, b = divmod(n.bit_length(), 2)
x = 2**(a+b)
while True:
y = (x + n//x)//2
if y >= x:
return x
x = y;
def next_prime(n):
for p in range(n+1, 2*n+1):
for i in range(2, isqrt(n)+1):
if p % i == 0:
break
else:
return p
return None
def A278116(n):
k = 0
p = 2
s2= (n**2)*p
s = s2
while True:
s_= s
k+= 1
p = next_prime(p)
s = (isqrt(s2//p)**2)*p
if s > s_:
break
return k
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jason Kimberley, Feb 12 2017
STATUS
approved