cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A139312 Characteristic function of the good primes (version 1).

This page as a plain text file.
%I A139312 #17 Jul 02 2025 23:40:19
%S A139312 0,1,0,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,1,
%T A139312 0,1,1,0,1,1,0,1,0,1,0,1,1,1,0,0,1,0,1,1,1,1,0,1,1,0,0,1,1,0,0,1,0,1,
%U A139312 0,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,0,0,1,1,0,0,1,1,0,1,0,0,1,0,1,0,1,1,1,0,0
%N A139312 Characteristic function of the good primes (version 1).
%C A139312 a(n)=1 if prime(n)^2 - prime(n-1)*prime(n+1) >=0, else a(n)=0.
%F A139312 a(n) = 1 if A056221(n-1)<=0, else a(n)=0.
%t A139312 f[n_] := If[ Prime[n]^2 - Prime[n - 1]*Prime[n + 1] > 0, 1, 0]; Array[f, 105, 2] (*alternative formula: derived*) Solve[x^2 - (x - a)*(x + b) == 0, x]; a = -Prime[n - 1] + Prime[n]; b = -Prime[n] + Prime[n + 1]; f[n_] = If[-Prime[-1 + n] + 2 Prime[n] - Prime[1 + n] == 0, 0, a*b/(b - a)]; Table[ If[ f[n] > 0, 0, 1], {n, 2, 106}]
%t A139312 If[#[[2]]^2-(#[[1]]#[[3]])>=0,1,0]&/@Partition[Prime[Range[110]],3,1] (* _Harvey P. Dale_, Jan 25 2015 *)
%o A139312 (PARI) a(n)=my(p=prime(n));p^2>=precprime(p-1)*nextprime(p+1) \\ _Charles R Greathouse IV_, Jun 24 2011
%Y A139312 Cf. A056221, A046869, A068828.
%K A139312 nonn,easy
%O A139312 2,1
%A A139312 _Roger L. Bagula_, Jun 07 2008
%E A139312 All entries corrected. - _R. J. Mathar_, _Charles R Greathouse IV_  _Robert G. Wilson v_, Jun 16 2011