|
MATHEMATICA
|
Needs[ NumberTheory`NumberTheoryFunctions`]; pm1[{k_}] := {1, k - 1}; pm1[lst_] := Module[{a, m, v}, a = lst[[1]]; m = Times @@ Rest[lst]; v = pm1[ Rest[lst]]; Union[ ChineseRemainder[{1, #}, {a, m}] & /@ v, ChineseRemainder[{-1, #}, {a, m}] & /@ v]]; nexttri[1] = 3; nexttri[n_] := Module[{s}, s = (pm1[Power @@ # & /@ FactorInteger[4n]]^2 - 1)/8; For[i = 1, True, i++, If[s[[i]] > n, Return[ s[[i]]] ]]]; a[0] = 15; a[n_] := a[n] = nexttri[ a[n - 1]]; Table[ a[n], {n, 0, 8}]
|
|
PROG
|
(Python)
from itertools import islice
from sympy import sqrt_mod_iter
def A068513_gen(): # generator of terms
a = 120
while True:
yield a>>3
b = a+1
for d in sqrt_mod_iter(1, a):
if d==1 or d**2-1 == a:
d += a
if d&1 and d < b:
b = d
a = b**2-1
|