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-10 of 53 results. Next

A105612 Number of nonzero quadratic residues (mod n) (cf. A000224).

Original entry on oeis.org

0, 1, 1, 1, 2, 3, 3, 2, 3, 5, 5, 3, 6, 7, 5, 3, 8, 7, 9, 5, 7, 11, 11, 5, 10, 13, 10, 7, 14, 11, 15, 6, 11, 17, 11, 7, 18, 19, 13, 8, 20, 15, 21, 11, 11, 23, 23, 7, 21, 21, 17, 13, 26, 21, 17, 11, 19, 29, 29, 11, 30, 31, 15, 11, 20, 23, 33, 17, 23, 23, 35, 11, 36, 37, 21, 19, 23
Offset: 1

Views

Author

Eric W. Weisstein, Apr 15 2005

Keywords

Programs

Formula

a(n) = A000224(n) - 1.
If p is an odd prime, then a(p) = (p - 1)/2. - Thomas Ordowski, Apr 09 2025

A037041 Number of quadratic residues mod n for some n (A000224 sorted and duplicates removed).

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 40, 42, 44, 45, 46, 48, 49, 51, 52, 53, 54, 55, 56, 57, 60, 62, 63, 64, 66, 68, 69, 70, 72, 74, 75, 76, 77, 79, 80, 81, 82, 84, 87, 88, 90, 91, 92, 93, 96, 97, 98
Offset: 1

Views

Author

Keywords

Programs

  • Maple
    N:= 100: # for terms <= N
    S:= {}:
    for i from 1 to N^2 do
      v:= A000224(i);
      if v <= N then
        S:= S union {v}
      fi;
    od:
    sort(convert(S,list)); # Robert Israel, Jul 20 2025

A123722 Values of n for which A000224(n)=Ceiling[(n+1)/3]; A000224(n) is the number of squares mod n.

Original entry on oeis.org

1, 3, 4, 8, 9, 15, 21, 33, 35, 39, 51, 57, 69, 70, 87, 93, 111, 123, 129, 141, 159, 177, 183, 201, 213, 219, 237, 249, 267, 291, 303, 309, 321, 327, 339, 381, 393, 411, 417, 447, 453, 471, 489, 501, 519, 537, 543, 573, 579, 591, 597, 633, 669, 681, 687, 699, 717
Offset: 1

Views

Author

John W. Layman, Oct 09 2006

Keywords

Comments

Conjecture. If n>2 and a(n) is a multiple of 3, then a(n)/3 is a prime; further, all odd primes are given as a(n)/3 for some n. (This has been verified up to n=2000.)

Crossrefs

A123723 Values of n for which A000224(n)=Ceiling[(n+1)/4], where A000224(n) is the number of squares mod n.

Original entry on oeis.org

1, 4, 8, 12, 20, 28, 44, 45, 52, 63, 68, 76, 92, 116, 124, 126, 148, 164, 172, 175, 188, 212, 236, 244, 268, 284, 292, 316, 332, 350, 356, 388, 404, 412, 428, 436, 452, 508, 524, 548, 556, 596, 604, 628, 652, 668, 692, 716, 724, 764, 772, 788, 796, 844, 892
Offset: 1

Views

Author

John W. Layman, Oct 12 2006

Keywords

Comments

Conjecture. If n>4 and a(n) is a multiple of 4, then a(n)/4 is a prime. (This has been verified up to n = 2000.)

Crossrefs

A096009 Duplicate of A000224.

Original entry on oeis.org

1, 2, 2, 2, 3, 4, 4, 3, 4, 6, 6, 4, 7, 8, 6, 4, 9, 8, 10, 6, 8, 12, 12, 6, 11, 14
Offset: 1

Views

Author

Keywords

A096008 Irregular triangle read by rows where n-th row contains all quadratic residues (including zero) mod n.

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 4, 0, 1, 3, 4, 0, 1, 2, 4, 0, 1, 4, 0, 1, 4, 7, 0, 1, 4, 5, 6, 9, 0, 1, 3, 4, 5, 9, 0, 1, 4, 9, 0, 1, 3, 4, 9, 10, 12, 0, 1, 2, 4, 7, 8, 9, 11, 0, 1, 4, 6, 9, 10, 0, 1, 4, 9, 0, 1, 2, 4, 8, 9, 13, 15, 16, 0, 1, 4, 7, 9, 10, 13, 16, 0, 1, 4, 5, 6, 7, 9, 11, 16, 17, 0, 1, 4, 5, 9, 16
Offset: 1

Views

Author

Cino Hilliard, Jul 20 2004

Keywords

Examples

			The table starts:
  [1]  [0]
  [2]  [0, 1]
  [3]  [0, 1]
  [4]  [0, 1]
  [5]  [0, 1, 4]
  [6]  [0, 1, 3, 4]
  [7]  [0, 1, 2, 4]
  [8]  [0, 1, 4]
  [9]  [0, 1, 4, 7]
  [10] [0, 1, 4, 5, 6, 9]
  ...
		

Crossrefs

Cf. A046071 (without zeros), A000224 (row lengths), A063987.
Last elements of rows give A047210.
Row sums give A165909.

Programs

  • Haskell
    a096008 n k = a096008_tabf !! (n-1) !! (k-1)
    a096008_row n = a096008_tabf !! (n-1)
    a096008_tabf = [0] : map (0 :) a046071_tabf
    -- Reinhard Zumkeller, May 10 2015
    
  • Maple
    q := n -> sort(convert({seq(i^2 mod n, i=0..n-1)}, list));
    # N. J. A. Sloane, Feb 09 2011
    # Alternative:
    QR := (a, n) -> NumberTheory:-QuadraticResidue(a, n):
    for n from 1 to 10 do print(select(a -> 1 = QR(a, n), [seq(0..n-1)])) od:
    # Peter Luschny, Jun 02 2024
  • Mathematica
    row[n_] := Table[PowerMod[k, 2, n], {k, 0, n-1}] // Union; Table[row[n], {n, 1, 20}] // Flatten (* Jean-François Alcover, Sep 09 2013 *)
    ResourceFunction["QuadraticResidues"] /@ Range[20] // Flatten  (* Peter Luschny, May 23 2024 *)
  • PARI
    T(n) = {local(v,r,i,j,k); v=vector(n,i,0); for(i=0,floor(n/2),v[i^2%n+1]=1); k=sum(i=1,n,v[i]); j=0; r=vector(k); for(i=1,n, if(v[i], j++; r[j]=i-1)); r}
    
  • SageMath
    for n in range(1, 11): print(quadratic_residues(n)) # Peter Luschny, Jun 02 2024

Extensions

Edited by Franklin T. Adams-Watters, Nov 07 2006

A046530 Number of distinct cubic residues mod n.

Original entry on oeis.org

1, 2, 3, 3, 5, 6, 3, 5, 3, 10, 11, 9, 5, 6, 15, 10, 17, 6, 7, 15, 9, 22, 23, 15, 21, 10, 7, 9, 29, 30, 11, 19, 33, 34, 15, 9, 13, 14, 15, 25, 41, 18, 15, 33, 15, 46, 47, 30, 15, 42, 51, 15, 53, 14, 55, 15, 21, 58, 59, 45, 21, 22, 9, 37, 25, 66, 23, 51, 69, 30, 71, 15, 25, 26, 63
Offset: 1

Views

Author

Keywords

Comments

In other words, number of distinct cubes mod n. - N. J. A. Sloane, Oct 05 2024
Cubic analog of A000224. - Steven Finch, Mar 01 2006
A074243 contains values of n such that a(n) = n. - Dmitri Kamenetsky, Nov 03 2012

Crossrefs

For number of k-th power residues mod n, see A000224 (k=2), A052273 (k=4), A052274 (k=5), A052275 (k=6), A085310 (k=7), A085311 (k=8), A085312 (k=9), A085313 (k=10), A085314 (k=12), A228849 (k=13).

Programs

  • Haskell
    import Data.List (nub)
    a046530 n = length $ nub $ map (`mod` n) $
                               take (fromInteger n) $ tail a000578_list
    -- Reinhard Zumkeller, Aug 01 2012
    
  • Maple
    A046530 := proc(n)
            local a,pf ;
            a := 1 ;
            if n = 1 then
                    return 1;
            end if;
            for i in  ifactors(n)[2] do
                    p := op(1,i) ;
                    e := op(2,i) ;
                    if p = 3 then
                            if e mod 3 = 0 then
                                    a := a*(3^(e+1)+10)/13 ;
                            elif e mod 3 = 1 then
                                    a := a*(3^(e+1)+30)/13 ;
                            else
                                    a := a*(3^(e+1)+12)/13 ;
                            end if;
                    elif p mod 3 = 2 then
                            if e mod 3 = 0 then
                                    a := a*(p^(e+2)+p+1)/(p^2+p+1) ;
                            elif e mod 3 = 1 then
                                    a := a*(p^(e+2)+p^2+p)/(p^2+p+1) ;
                            else
                                    a := a*(p^(e+2)+p^2+1)/(p^2+p+1) ;
                            end if;
                    else
                            if e mod 3 = 0 then
                                    a := a*(p^(e+2)+2*p^2+3*p+3)/3/(p^2+p+1) ;
                            elif e mod 3 = 1 then
                                    a := a*(p^(e+2)+3*p^2+3*p+2)/3/(p^2+p+1) ;
                            else
                                    a := a*(p^(e+2)+3*p^2+2*p+3)/3/(p^2+p+1) ;
                            end if;
                    end if;
            end do:
            a ;
    end proc:
    seq(A046530(n),n=1..40) ; # R. J. Mathar, Nov 01 2011
  • Mathematica
    Length[Union[#]]& /@ Table[Mod[k^3, n], {n, 75}, {k, n}] (* Jean-François Alcover, Aug 30 2011 *)
    Length[Union[#]]&/@Table[PowerMod[k,3,n],{n,80},{k,n}] (* Harvey P. Dale, Aug 12 2015 *)
  • PARI
    g(p,e)=if(p==3,(3^(e+1)+if(e%3==1,30,if(e%3,12,10)))/13, if(p%3==2, (p^(e+2)+if(e%3==1,p^2+p,if(e%3,p^2+1,p+1)))/(p^2+p+1),(p^(e+2)+if(e%3==1,3*p^2+3*p+2, if(e%3,3*p^2+2*p+3,2*p^2+3*p+3)))/3/(p^2+p+1)))
    a(n)=my(f=factor(n));prod(i=1,#f[,1],g(f[i,1],f[i,2])) \\ Charles R Greathouse IV, Jan 03 2013
    
  • PARI
    a(n)={my(f=factor(n)); prod(i=1, #f~, my(p=f[i,1], e=f[i,2]); 1 + sum(i=0, (e-1)\3, if(p%3==1 || (p==3&&3*iAndrew Howroyd, Jul 17 2018

Formula

a(n) = n - A257301(n). - Stanislav Sykora, Apr 21 2015
a(2^n) = A046630(n). a(3^n) = A046631(n). a(5^n) = A046633(n). a(7^n) = A046635(n). - R. J. Mathar, Sep 28 2017
Multiplicative with a(p^e) = 1 + Sum_{i=0..floor((e-1)/3)} (p - 1)*p^(e-3*i-1)/k where k = 3 if (p = 3 and 3*i + 1 = e) or (p mod 3 = 1) otherwise k = 1. - Andrew Howroyd, Jul 17 2018
Sum_{k=1..n} a(k) ~ c * n^2/log(n)^(1/3), where c = (6/(13*Gamma(2/3))) * (2/3)^(-1/3) * Product_{p prime == 2 (mod 3)} (1 - (p^2+1)/((p^2+p+1)*(p^2-p+1)*(p+1))) * (1-1/p)^(-1/3) * Product_{p prime == 1 (mod 3)} (1 - (2*p^4+3*p^2+3)/(3*(p^2+p+1)*(p^2-p+1)*(p+1))) * (1-1/p)^(-1/3) = 0.48487418844474389597... (Finch and Sebah, 2006). - Amiram Eldar, Oct 18 2022

A046073 Number of squares in multiplicative group modulo n.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 3, 1, 3, 2, 5, 1, 6, 3, 2, 2, 8, 3, 9, 2, 3, 5, 11, 1, 10, 6, 9, 3, 14, 2, 15, 4, 5, 8, 6, 3, 18, 9, 6, 2, 20, 3, 21, 5, 6, 11, 23, 2, 21, 10, 8, 6, 26, 9, 10, 3, 9, 14, 29, 2, 30, 15, 9, 8, 12, 5, 33, 8, 11, 6, 35, 3, 36, 18, 10, 9, 15, 6, 39, 4, 27, 20, 41, 3, 16, 21
Offset: 1

Views

Author

Keywords

Comments

a(n) is the number of different diagonal elements in Cayley table for multiplicative group modulo n. But the fact that the same number of different elements are on the diagonal of the Cayley table does not mean in every case that these groups are isomorphic. - Artur Jasinski, Jul 03 2010
The number of quadratic residues modulo n that are coprime to n. These residues are listed in A096103. - Peter Munn, Mar 10 2021

References

  • Daniel Shanks, Solved and Unsolved Problems in Number Theory, 4th ed. New York: Chelsea, p. 95, 1993.

Crossrefs

Row lengths of A096103.
Positions of ones: A018253.

Programs

  • Maple
    F:= n -> nops({seq}(`if`(igcd(t,n)=1,t^2 mod n,NULL), t=1..floor(n/2))):
    1, seq(F(n), n=2..100); # Robert Israel, Jan 04 2015
    # 2nd program
    A046073 := proc(n)
        local a,p,e,pf;
        a := 1;
        for pf in ifactors(n)[2] do
            p := op(1,pf) ;
            e := op(2,pf) ;
            if p = 2 then
                a := a*p^max(e-3,0) ;
            else
                a := a*(p-1)/2*p^(e-1) ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Oct 03 2016
  • Mathematica
    Table[EulerPhi[n]/Sum[Boole[Mod[k^2, n] == 1] + Boole[n == 1], {k, n}], {n, 86}] (* or *)
    Table[Apply[Times, FactorInteger[n] /. {p_, e_} /; p > 0 :> Which[p == 1, 1, p == 2, 2^Max[e - 3, 0], True, (p - 1) p^(e - 1)/2]], {n, 86}] (* Michael De Vlieger, Jul 18 2017 *)
  • PARI
    A060594(n) = if(n<=2, 1, 2^#znstar(n)[3]); \\ This function from Joerg Arndt, Jan 06 2015
    A046073(n) = eulerphi(n)/A060594(n); \\ Antti Karttunen, Jul 17 2017, after Sharon Sela's Mar 09 2002 formula.
    
  • PARI
    A046073(n)=if(n>4,(n=znstar(n))[1]>>#n[3],1) \\ Avoids duplicate computation of phi(n). - M. F. Hasler, Nov 27 2017, typo fixed Mar 11 2021
    
  • Python
    from sympy import factorint, prod
    def a(n): return 1 if n==1 else prod([2**max(e - 3, 0) if p==2 else (p - 1)*p**(e - 1)//2 for p, e in factorint(n).items()])
    print([a(n) for n in range(1, 51)]) # Indranil Ghosh, Jul 17 2017
  • Scheme
    (define (A046073 n) (cond ((= 1 n) n) ((even? n) (* (A000079 (max (- (A007814 n) 3) 0)) (A046073 (A028234 n)))) (else (* (/ 1 2) (- (A020639 n) 1) (/ (A028233 n) (A020639 n)) (A046073 (A028234 n)))))) ;; Antti Karttunen, Jul 17 2017, after the given multiplicative formula.
    

Formula

a(n) * A060594(n) = A000010(n) = phi(n) (This gives a formula for a(n) using the one in A060594(n) ). - Sharon Sela (sharonsela(AT)hotmail.com), Mar 09 2002
Multiplicative with a(2^e) = 2^max(e-3,0), a(p^e) = (p-1)*p^(e-1)/2 for p an odd prime.
Sum_{k=1..n} a(k) ~ c * n^2/sqrt(log(n)), where c = (43/(80*sqrt(Pi))) * Product_{p prime} (1+1/(2*p))*sqrt(1-1/p) = 0.24627260085060864229... (Finch and Sebah, 2006). - Amiram Eldar, Oct 18 2022

Extensions

Edited and verified by Franklin T. Adams-Watters, Nov 07 2006

A023105 Number of distinct quadratic residues mod 2^n.

Original entry on oeis.org

1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847, 43692, 87383, 174764, 349527, 699052, 1398103, 2796204, 5592407, 11184812, 22369623, 44739244, 89478487, 178956972, 357913943, 715827884, 1431655767, 2863311532
Offset: 0

Views

Author

Keywords

Comments

Number of distinct n-digit suffixes of base 2 squares.
a(n) counts the elements of A234000 smaller than 2^n plus the zero: a(7)=23 counts the elements of {0, 1, 4, 9, ..., 113, 121}, for example. - R. J. Mathar, Oct 11 2014
Conjecture: a(n) = 2 + (the number of A004215 entries < 2^n), for n>0. - Tilman Neumann, Sep 20 2020

Crossrefs

Programs

  • Haskell
    a 0 = 1
    a 1 = 2
    a n | even n = 2*a(n-1)-2
    a n | odd  n = 2*a(n-1)-1
    -- James Spahlinger, Oct 07 2012
    
  • Magma
    [Floor((2^n+10)/6): n in [0..30]]; // Vincenzo Librandi, Apr 21 2012
    
  • Mathematica
    CoefficientList[Series[(1-3*x^2-x^3)/((1-x)*(1+x)*(1-2*x)),{x,0,35}],x] (* Vincenzo Librandi, Apr 21 2012 *)
    LinearRecurrence[{2,1,-2},{1,2,2,3},40] (* Harvey P. Dale, Mar 05 2016 *)
  • PARI
    a(n)=(2^n+10)\6 \\ Charles R Greathouse IV, Apr 21 2012
    
  • Python
    def A023105(n): return ((1<Chai Wah Wu, Aug 22 2023
  • SageMath
    [(2^n +9 -(-1)^n -3*bool(n==0))/6 for n in (0..30)] # G. C. Greubel, Aug 10 2022
    

Formula

a(n) = floor( (2^n+10)/6 ).
a(n) = (2^n + 9 - (-1)^n)/6 for n > 0. - David S. Dodson, Jan 06 2013
G.f.: (1-3*x^2-x^3)/((1-x)*(1+x)*(1-2*x)). - Colin Barker, Mar 08 2012
a(0)=1, a(1)=2. a(n) = 2*a(n-1)-2 if n is even, a(n) = 2*a(n-1)-1 if n is odd. - Vincenzo Librandi, Apr 21 2012
a(n) = 2*a(n-1) + a(n-2) - 2*a(n-3) for n > 0. - Joerg Arndt, Apr 21 2012
a(0)=1, a(1)=2, a(n+2) = a(n+1) + A001045(n) for n >= 1. - Lee Hae-hwang, Jun 16 2014
a(n) = A000224(2^n). - R. J. Mathar, Oct 10 2014
a(n) = A005578(n-1) + 1, n > 0. - Carl Joshua Quines, Jul 17 2019
E.g.f.: (exp(2*x) + 9*exp(x) - 3 - exp(-x))/6. - G. C. Greubel, Aug 10 2022

A304034 Number of ways to write n as p + 2^k + (1+(n mod 2))*3^m with p prime, where k and m are positive integers with 2^k + (1+(n mod 2))*3^m squarefree.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 2, 1, 3, 1, 4, 2, 5, 1, 3, 2, 5, 1, 7, 3, 3, 4, 4, 4, 6, 2, 3, 5, 6, 2, 7, 3, 5, 5, 6, 5, 9, 3, 4, 6, 7, 2, 12, 2, 5, 6, 7, 4, 10, 3, 3, 5, 8, 2, 8, 3, 4, 6, 8, 5, 9, 4, 2, 7, 7, 3, 13, 5, 5, 9, 7, 5, 13, 3, 6, 10, 7, 5, 10, 5, 7, 7, 9, 8, 13
Offset: 1

Views

Author

Zhi-Wei Sun, May 06 2018

Keywords

Comments

Conjecture: a(n) > 0 for all n > 11.
This has been verified for n up to 10^10.
See also A304081 for a similar conjecture.

Examples

			a(8) = 1 since 8 = 3 + 2^1 + 3^1 with 3 prime and 2^1 + 3^1 = 5 squarefree.
a(13) = 1 since 13 = 3 + 2^2 + 2*3^1 with 3 prime and 2^2 + 2*3^1 = 2*5 squarefree.
a(19) = 1 since 19 = 5 + 2^3 + 2*3^1 with 5 prime and 2^3 + 2*3^1 = 2*7 squarefree.
a(23) = 1 since 23 = 13 + 2^2 + 2*3^1 with 13 prime and 2^2 + 2*3 = 2*5 squarefree.
		

Crossrefs

Programs

  • Mathematica
    tab={};Do[r=0;Do[If[SquareFreeQ[2^k+(1+Mod[n,2])*3^m]&&PrimeQ[n-2^k-(1+Mod[n,2])*3^m],r=r+1],{k,1,Log[2,n]},{m,1,If[2^k==n,-1,Log[3,(n-2^k)/(1+Mod[n,2])]]}];tab=Append[tab,r],{n,1,90}];Print[tab]
Showing 1-10 of 53 results. Next