OFFSET
1,1
COMMENTS
Conjecture: a(n) > 0.
a(n) = (x^2-1)/8 where x is the least odd solution > 1 of the Pell-like equation x^2 - prime(n)*y^2 = 1 - prime(n). - Robert Israel, Jan 08 2015
LINKS
Robert Israel, Table of n, a(n) for n = 1..1000 (n = 1..200 from Zak Seidov).
EXAMPLE
See A225502.
MAPLE
F:= proc(n) local p, S, x, y, z, cands, s;
p:= ithprime(n);
S:= {isolve(x^2 - p*y^2 = 1-p)};
for z from 0 do
cands:= select(s -> (subs(s, x) > 1 and subs(s, x)::odd), simplify(eval(S, _Z1=z)));
if cands <> {} then
x:= min(map(subs, cands, x));
return((x^2-1)/8)
fi
od;
end proc:
map(F, [$1..100]); # Robert Israel, Jan 08 2015
MATHEMATICA
a[n_] := Module[{p, x0, sol, x, y}, p = Prime[n]; x0 = Which[n == 1, 7, n == 2, 5, True, sol = Table[Solve[x > 1 && y > 1 && x^2 - p y^2 == 1 - p, {x, y}, Integers] /. C[1] -> c, {c, 0, 1}] // Simplify; Select[x /. Flatten[sol, 1], OddQ] // Min]; (x0^2 - 1)/8];
Array[a, 171] (* Jean-François Alcover, Apr 02 2019, after Robert Israel *)
PROG
(C)
#include <stdio.h>
#define TOP 300
typedef unsigned long long U64;
U64 isTriangular(U64 a) {
U64 sr = 1ULL<<32, s, b, t;
if (a < (sr/2)*(sr+1)) sr>>=1;
while (a < sr*(sr+1)/2) sr>>=1;
for (b = sr>>1; b; b>>=1) {
s = sr+b;
if (s&1) t = s*((s+1)/2);
else t = (s/2)*(s+1);
if (t >= s && a >= t) sr = s;
}
return (sr*(sr+1)/2 == a);
}
int main() {
U64 i, j, k, m, tm, p, pp = 1, primes[TOP];
for (primes[0]=2, i = 3; pp < TOP; i+=2) {
for (p = 1; p < pp; ++p) if (i%primes[p]==0) break;
if (p==pp) {
primes[pp++] = i;
for (j=p=primes[pp-2], m=tm=1; ; j=k, m++, tm+=m) {
if ((k = p*tm) < j) k=0;
if (isTriangular(k)) break;
}
printf("%llu, ", k);
}
}
return 0;
}
(PARI) a(n) = {p = prime(n); k = 1; while (! ((t=k*(k+1)/2) && ((t % p) == 0) && ispolygonal(t/p, 3)), k++); t; } \\ Michel Marcus, Jan 08 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, May 09 2013
EXTENSIONS
a(171) from Giovanni Resta, Jun 19 2013
STATUS
approved