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.

Showing 1-3 of 3 results.

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

Original entry on oeis.org

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, 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, 37, 39, 41, 39, 41, 41, 39, 45, 55, 55, 53, 53, 63, 65, 2, 69, 69, 71, 2, 3, 4, 3
Offset: 1

Views

Author

N. J. A. Sloane, Daniel Wild (wild(AT)edumath.u-strasbg.fr)

Keywords

Crossrefs

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.
For records see A127149, A127150.

Programs

  • Haskell
    a004648 n = a004648_list !! (n-1)
    a004648_list = zipWith mod a000040_list [1..]
    -- Reinhard Zumkeller, Jul 30 2012
    
  • Magma
    [(NthPrime(n) mod n): n in [1..100]]; // Vincenzo Librandi, Apr 06 2011
    
  • Maple
    A004648 := proc(n)
        modp(ithprime(n),n) ;
    end proc: # R. J. Mathar, Dec 02 2014
  • Mathematica
    Table[Mod[Prime[n], n], {n, 100}] (* Zak Seidov, Apr 25 2005 *)
  • PARI
    for(n=1,100,print1(prime(n)%n,","))
    
  • Python
    from sympy import prime; print([prime(i) % i for i in range(1, 101)]) # Jwalin Bhatt, Jul 29 2025
  • SageMath
    def A004648(n): return (nth_prime(n)%n)
    [A004648(n) for n in range(1,101)] # G. C. Greubel, Apr 20 2023
    

Formula

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

Extensions

More terms from Clark Kimberling
Corrected by Jaroslav Krizek, Dec 16 2009

A127150 Where records occur in A004648.

Original entry on oeis.org

1, 2, 3, 4, 9, 10, 19, 20, 22, 23, 24, 25, 26, 48, 54, 55, 56, 57, 62, 63, 67, 68, 70, 72, 127, 128, 129, 130, 131, 133, 134, 136, 138, 139, 140, 142, 147, 151, 155, 157, 158, 159, 162, 163, 166, 167, 168, 169, 173, 176, 178, 182, 187, 188, 189, 298, 300, 310, 311, 313, 320
Offset: 1

Views

Author

N. J. A. Sloane, Mar 25 2007

Keywords

Crossrefs

Programs

  • Mathematica
    Module[{r = -1, v}, Table[If[(v = Mod[Prime[k], k]) > r, r = v; k, Nothing], {k, 500}]] (* Paolo Xausa, Jul 29 2025 *)

A125718 a(1)=1. a(n) = the smallest positive integer not occurring earlier in the sequence such that the n-th prime is congruent to a(n) (mod n).

Original entry on oeis.org

1, 3, 2, 7, 6, 13, 10, 11, 5, 9, 20, 25, 15, 29, 17, 21, 8, 43, 48, 31, 52, 35, 14, 41, 22, 23, 49, 51, 80, 53, 34, 67, 38, 37, 44, 79, 46, 87, 50, 93, 56, 55, 19, 61, 62, 107, 70, 127, 129, 179, 131, 83, 82, 89, 92, 39, 98, 97, 100, 101, 161, 45, 118, 119, 183, 185, 63, 65
Offset: 1

Views

Author

Leroy Quet, Feb 01 2007

Keywords

Comments

This sequence seems likely to be a permutation of the positive integers. It will be if every positive number appears in A004648 (cf. A127149, A127150).
If this is a permutation of the positive integers, then A249678 is the inverse permutation. - M. F. Hasler, Nov 03 2014

Crossrefs

Cf. A004648.

Programs

  • Mathematica
    f[l_List] := Block[{n = Length[l] + 1, k = Mod[Prime[n], n, 1]},While[MemberQ[l, k], k += n];Append[l, k]];Nest[f, {1}, 70] (* Ray Chandler, Feb 04 2007 *)
  • PARI
    {Quet_p3(n)= /* Permutation sequence a'la Leroy Quet, A125718 */local(x=[1],k=0,w=1); for(i=2,n,if((k=prime(i)%i)==0,k=i);while(bittest(w,k-1)>0,k+=i);x=concat(x,k);w+=2^(k-1));return(x)}
    
  • PARI
    A125718(n,show=0,u=1)={for(n=1,n,p=prime(n)%n;while(bittest(u,p),p+=n);u+=1<M. F. Hasler, Nov 03 2014

Extensions

Extended by Ray Chandler, Feb 04 2007
Showing 1-3 of 3 results.