login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = prime(n) mod n.
57

%I #32 Apr 21 2023 02:12:05

%S 0,1,2,3,1,1,3,3,5,9,9,1,2,1,2,5,8,7,10,11,10,13,14,17,22,23,22,23,22,

%T 23,3,3,5,3,9,7,9,11,11,13,15,13,19,17,17,15,23,31,31,29,29,31,29,35,

%U 37,39,41,39,41,41,39,45,55,55,53,53,63,65,2,69,69,71,2,3,4,3

%N a(n) = prime(n) mod n.

%H N. J. A. Sloane, <a href="/A004648/b004648.txt">Table of n, a(n) for n = 1..10000</a>

%H E. Labos, <a href="/A004648/a004648.gif">Graph of first 50000 terms</a>

%F a(n) = prime(n) - n*floor(prime(n)/n)

%p A004648 := proc(n)

%p modp(ithprime(n),n) ;

%p end proc: # _R. J. Mathar_, Dec 02 2014

%t Table[Mod[Prime[n], n], {n, 100}] (* _Zak Seidov_, Apr 25 2005 *)

%o (PARI) for(n=1,100,print1(prime(n)%n,","))

%o (Magma) [(NthPrime(n) mod n): n in [1..100]]; // _Vincenzo Librandi_, Apr 06 2011

%o (Haskell)

%o a004648 n = a004648_list !! (n-1)

%o a004648_list = zipWith mod a000040_list [1..]

%o -- _Reinhard Zumkeller_, Jul 30 2012

%o (SageMath)

%o def A004648(n): return (nth_prime(n)%n)

%o [A004648(n) for n in range(1,101)] # _G. C. Greubel_, Apr 20 2023

%Y 1's occur at A023143, 2's at A023144, 3's at A023145, 4's at A023146, 5's at A023147, 6's at A023148, 7's at A023149, 8's at A023150, 9's at A023151, 10's at A023152, == -1's at A045924.

%Y For records see A127149, A127150.

%K nonn

%O 1,3

%A _N. J. A. Sloane_, Daniel Wild (wild(AT)edumath.u-strasbg.fr)

%E More terms from _Clark Kimberling_

%E Corrected by _Jaroslav Krizek_, Dec 16 2009