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.

A051698 Closest prime to n that is different from n (break ties by taking the smaller prime).

This page as a plain text file.
%I A051698 #12 Jul 02 2025 16:01:58
%S A051698 2,2,3,2,3,3,5,5,7,7,11,13,11,11,13,13,17,19,17,17,19,19,23,19,23,23,
%T A051698 23,29,29,31,29,29,31,31,31,37,37,41,37,37,41,43,41,41,43,43,47,43,47,
%U A051698 47,47,53,53,47,53,53,53,59,59,61,59,59,61,61,61,67,67,71,67,67,71,73
%N A051698 Closest prime to n that is different from n (break ties by taking the smaller prime).
%H A051698 Harvey P. Dale, <a href="/A051698/b051698.txt">Table of n, a(n) for n = 0..1000</a>
%e A051698 Closest primes to 0,1,2,3,4 are 2,2,3,2,3.
%t A051698 cp[n_]:=Module[{p1=NextPrime[n,-1],p2=NextPrime[n]},If[p2-n<n-p1,p2,p1]]; Join[{2},Table[cp[k],{k,80}]] (* _Harvey P. Dale_, Dec 11 2018 *)
%Y A051698 Related sequences: A023186-A023188, A046929-A046931, A051650, A051652, A051697-A051702, A051728-A051730.
%K A051698 nonn,easy
%O A051698 0,1
%A A051698 _N. J. A. Sloane_
%E A051698 More terms from _James Sellers_