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.

User: Peter Schorn

Peter Schorn's wiki page.

Peter Schorn has authored 7 sequences.

A380816 Number of pairs (x, y) with 0 < x < y < n such that x^y = y^x modulo n.

Original entry on oeis.org

0, 0, 0, 0, 1, 1, 5, 2, 2, 3, 5, 6, 8, 8, 6, 18, 11, 7, 20, 16, 15, 17, 28, 28, 15, 23, 32, 27, 24, 22, 35, 88, 20, 31, 19, 34, 32, 43, 35, 72, 33, 40, 37, 52, 45, 51, 57, 134, 36, 37, 38, 73, 65, 73, 61, 118, 72, 52, 59, 94, 61, 74, 111, 428, 67, 65, 69
Offset: 1

Author

Peter Schorn, Feb 04 2025

Keywords

Examples

			For n < 5 there are no (x, y) with 0 < x < y < n such that x^y = y^x modulo n. Therefore a(n) = 0.
For n = 5 and 6 there is only 2^4 = 4^2 modulo n which makes a(5) = a(6) = 1.
For n = 7, there is 2^4=4^2, 2^5=5^2, 2^6=6^2, 4^5=5^4 and 4^6=6^4 modulo 7 which makes a(7) = 5.
		

Programs

  • Mathematica
    A380816[n_] := Sum[Boole[PowerMod[x, y, n] == PowerMod[y, x, n]], {x, 2, n-2}, {y, x+1, n-1}];
    Array[A380816, 100] (* Paolo Xausa, Mar 17 2025 *)
  • PARI
    a(n)={my(c=0);for(x=1,n-1,for(y=x+1,n-1,if(Mod(x,n)^y==Mod(y,n)^x,c++)));c}
    
  • Python
    def A380816(n): return sum(1 for x in range(1,n-1) for y in range(x+1,n) if pow(x,y,n)==pow(y,x,n)) # Chai Wah Wu, Feb 12 2025

A363340 a(n) is the smallest positive integer such that a(n) * n is the sum of two squares.

Original entry on oeis.org

1, 1, 3, 1, 1, 3, 7, 1, 1, 1, 11, 3, 1, 7, 3, 1, 1, 1, 19, 1, 21, 11, 23, 3, 1, 1, 3, 7, 1, 3, 31, 1, 33, 1, 7, 1, 1, 19, 3, 1, 1, 21, 43, 11, 1, 23, 47, 3, 1, 1, 3, 1, 1, 3, 11, 7, 57, 1, 59, 3, 1, 31, 7, 1, 1, 33, 67, 1, 69, 7, 71, 1, 1, 1, 3, 19, 77, 3, 79
Offset: 1

Author

Peter Schorn, May 28 2023

Keywords

Comments

Using Fermat's two-squares theorem it is easy to see that a(n) is the product of all prime factors of n that are congruent to 3 modulo 4 and have an odd exponent.
This implies that a(n) is also the smallest positive integer such that n / a(n) is the sum of two squares.
Equivalently, a(n) is the product of all primes of the form 4k+3 that divide the squarefree part of n. If we use the squarefree kernel instead, we get A170819. - Peter Munn, Aug 06 2023

Examples

			a(1) = a(2) = 1 since 1 and 2 are sums of two squares.
a(3) = 3 since 3 and 6 are not sums of two squares but 3*3 is.
a(6) = 3 since 6 and 12 are not sums of two squares but 3*6 = 3^2 + 3^2.
		

Crossrefs

Cf. A001481 (positions of 1's), A167181 (range of values).
Fixed points: A167181.

Programs

  • PARI
    a(n) = my(r=1); foreach(mattranspose(factor(n)), f, if(f[1]%4==3&&f[2]%2==1, r*=f[1])); r

Formula

Multiplicative with a(p^e) = p if p^e == 3 (mod 4), otherwise 1. - Peter Munn, Jul 03 2023
From Peter Munn, Aug 06 2023: (Start)
a(n) = A007913(A097706(n)) = A097706(A007913(n)).
a(n) == A000265(n) (mod 4).
a(A059897(n, k)) = A059897(a(n), a(k)).
(End)

A354761 Least number of squares and cubes that add up to n.

Original entry on oeis.org

1, 2, 3, 1, 2, 3, 4, 1, 1, 2, 3, 2, 2, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 1, 2, 1, 2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 3, 3, 2, 2, 3, 2, 2, 2, 3, 3, 3, 1, 2, 3, 2, 2, 2, 3, 3, 2, 2, 3, 3, 2, 3, 2, 1, 2, 3, 3, 2, 3, 3, 3, 2, 2, 2, 3, 2, 3, 3, 3, 2, 1, 2, 3, 3, 2, 3
Offset: 1

Author

Peter Schorn, Jun 06 2022

Keywords

Comments

a(n) <= 4 since any number can be written as a sum of 4 squares (Lagrange's theorem).
Sequence first differs from A063274, A225926 and A274459 at n = 32 since 32 is a powerful number, a prime power and a perfect power but neither a square nor a cube.

Examples

			a(1) = 1, a(4) = 1 (4 = 2^2), a(7) = 4 (7 = 2^2 + 1^2 + 1^2 + 1^2), a(8) = 1 (8 = 2^3), a(12) = 2 (12 = 2^3 + 2^2), a(17) = 2 (17 = 4^2 + 1^2), a(32) = 2 (32 = 4^2 + 4^2).
		

Programs

  • PARI
    lista(n) = {my(v = vector(n)); for(j = 2, 3, for(i = 2, sqrtnint(n, j), v[i^j] = 1)); v[1]=1; v[2]=2; for(i=3, #v, if(v[i]==0, v[i] = vecmin(vector(i\2, k, v[k] + v[i-k])))); v}

A343923 If n = Product (p_j^k_j) then a(n) = Sum (abs(p_j-k_j)) (a(1) = 0 by convention).

Original entry on oeis.org

0, 1, 2, 0, 4, 3, 6, 1, 1, 5, 10, 2, 12, 7, 6, 2, 16, 2, 18, 4, 8, 11, 22, 3, 3, 13, 0, 6, 28, 7, 30, 3, 12, 17, 10, 1, 36, 19, 14, 5, 40, 9, 42, 10, 5, 23, 46, 4, 5, 4, 18, 12, 52, 1, 14, 7, 20, 29, 58, 6, 60, 31, 7, 4, 16, 13, 66, 16, 24, 11, 70, 2, 72
Offset: 1

Author

Peter Schorn, May 04 2021

Keywords

Examples

			a(24) = a(2^3 * 3) = abs(2 - 3) + abs(3 - 1) = 3. a(27) = a(3^3) = 0.
		

Crossrefs

Cf. A008474.

Programs

  • Mathematica
    a[n_] := Plus @@ (Abs[#[[1]] - #[[2]]] & /@ FactorInteger[n]); Array[a, 100] (* Amiram Eldar, May 04 2021 *)
  • PARI
    a(n)=local(t); if(n<1, 0, t=factor(n); vecsum(abs(t[,1]-t[,2])))

Formula

Additive with a(p^e) = abs(p-e).

A342176 Tower of primes modulo n: a(n) = (2^3^5^7^ ... ^prime(n)) mod n.

Original entry on oeis.org

0, 0, 2, 0, 3, 2, 1, 0, 8, 8, 8, 8, 8, 8, 8, 0, 8, 8, 18, 8, 8, 8, 2, 8, 8, 8, 26, 8, 26, 8, 8, 0, 8, 8, 8, 8, 6, 18, 8, 8, 8, 8, 32, 8, 8, 2, 7, 32, 29, 8, 8, 8, 18, 26, 8, 8, 56, 26, 42, 8, 8, 8, 8, 0, 8, 8, 58, 8, 2, 8, 18, 8, 1, 6, 8, 56
Offset: 1

Author

Peter Schorn, Mar 04 2021

Keywords

Comments

a(n) = 0 iff n is a power of 2.

Examples

			a(1) = 0 = 2 mod 1. a(2) = 0 = 2^3 mod 2. a(3) = 2 = 2^3^5 = 2^243 = 2 mod 3.
		

Crossrefs

Cf. A000040.

Programs

  • PARI
    { a(n, m=n, s=2) = local(g); if(s==prime(n), return(n%m)); g=s^valuation(m, s); m\=g; lift(chinese(Mod(0, g), Mod(s, m)^a(n, eulerphi(m), nextprime(s+1)) )) }

A334819 Largest quadratic nonresidue modulo n (with n >= 3).

Original entry on oeis.org

2, 3, 3, 5, 6, 7, 8, 8, 10, 11, 11, 13, 14, 15, 14, 17, 18, 19, 20, 21, 22, 23, 23, 24, 26, 27, 27, 29, 30, 31, 32, 31, 34, 35, 35, 37, 38, 39, 38, 41, 42, 43, 44, 45, 46, 47, 48, 48, 50, 51, 51, 53, 54, 55, 56, 56, 58, 59, 59, 61, 62, 63, 63, 65, 66, 67
Offset: 3

Author

Peter Schorn, May 12 2020

Keywords

Comments

The largest nonnegative integer less than n which is not a square modulo n.
If p is a prime congruent 3 modulo 4 then a(p) = p-1 since -1 is not a quadratic residue for such primes.

Examples

			The squares modulo 3 are 0 and 1. Therefore a(3) = 2. The nonsquares modulo 4 are 2 and 3 which makes a(4) = 3. Modulo 5 we have 0, 1 and 4 as squares giving a(5) = 3. 0, 1 and 4 are also the squares modulo 6 resulting in a(6) = 5. Since 10007 is a prime of the form 4*k + 3, a(10007) = 10006.
		

Crossrefs

Cf. A020649, A047210 (the largest square modulo n), A192450 (a(n)=n-1).

Programs

  • Maple
    f:= proc(n) local k;
      for k from n-1 by -1 do if numtheory:-msqrt(k,n)=FAIL then return k fi
      od
    end proc:
    map(f, [$3..100]); # Robert Israel, May 14 2020
  • Mathematica
    a[n_] := Module[{r}, For[r = n-1, r >= 1, r--, If[!IntegerQ[Sqrt[Mod[r, n]] ], Return[r]]]];
    a /@ Range[3, 100] (* Jean-François Alcover, Aug 15 2020 *)
  • PARI
    a(n) = forstep(r = n - 1, 1, -1, if(!issquare(Mod(r, n)), return(r)))

A333669 The smallest nontrivial quadratic residue modulo n.

Original entry on oeis.org

4, 3, 2, 4, 4, 4, 3, 4, 3, 2, 4, 4, 2, 4, 4, 4, 4, 3, 2, 4, 4, 3, 4, 4, 4, 4, 2, 4, 3, 2, 4, 4, 3, 4, 3, 4, 2, 4, 4, 4, 4, 2, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 3, 2, 4, 4, 4, 3, 4, 4, 3, 4, 2, 4, 2, 3, 4, 4, 4, 3, 2, 4, 4, 2, 3, 4, 4, 4, 4, 4
Offset: 5

Author

Peter Schorn, May 07 2020

Keywords

Comments

The values are 2, 3 and 4. If 2 is a square modulo n (see A057126) the value is 2. Otherwise, if 3 is a square modulo n (see A057125) the value is 3. If neither 2 or 3 are a square modulo n the value is 4.
Dedicated to Urs Meyer at the occasion of his 60th birthday.

Examples

			The squares modulo 5 are 1 and 4, therefore a(5) = 4.
Modulo 6 the squares are 1, 3 and 4 which makes a(6) = 3.
a(7) = 2 since 2 == 3^2 (mod 7).
		

Crossrefs

Cf. A057126 for the n where the value is 2 and A057125 for the n where the value is 3 if n was not in A057126.

Programs

  • Maple
    f:= proc(n) uses numtheory; if quadres(2,n)=1 then 2 elif quadres(3,n)=1 then 3 else 4 fi end proc:
    map(f, [$5..100]); # Robert Israel, Sep 15 2020
  • Mathematica
    qrQ[m_, n_] := Module[{k}, Reduce[Mod[m-k^2, n]==0, k, Integers] =!= False];
    a[n_] := If[qrQ[2, n], 2, If[qrQ[3, n], 3, 4]];
    a /@ Range[5, 100] (* Jean-François Alcover, Oct 25 2020 *)
  • PARI
    a(n) = if(issquare(Mod(2,n)),2,issquare(Mod(3,n)),3,4)