login
The number of one-digit numbers, k, in base n such that k^2 and k^3 end in the same digit.
1

%I #46 Sep 07 2023 07:15:19

%S 1,2,2,3,2,4,2,3,4,4,2,6,2,4,4,5,2,8,2,6,4,4,2,6,6,4,4,6,2,8,2,5,4,4,

%T 4,12,2,4,4,6,2,8,2,6,8,4,2,10,8,12,4,6,2,8,4,6,4,4,2,12,2,4,8,9,4,8,

%U 2,6,4,8,2,12,2,4,12,6,4,8,2,10,10,4,2,12,4

%N The number of one-digit numbers, k, in base n such that k^2 and k^3 end in the same digit.

%C It appears that a(n) is equal to the number of factors of n, except when n cannot be divided by its multiplicative projection (A230542). - Ian Newman, Jun 01 2018

%C Number of solutions to x^3 - x^2 == 0 (mod n). - _Andrew Howroyd_, Jul 22 2018

%H Matthew Scroggs, <a href="/A305461/b305461.txt">Table of n, a(n) for n = 1..1000</a>

%H Matthew Scroggs, <a href="http://www.mscroggs.co.uk/puzzles/159">Square and cube endings</a>.

%F Multiplicative with a(p^e) = p^floor(e/2) + 1 for prime p. - _Andrew Howroyd_, Jul 22 2018

%e In base 4,

%e 0^2 = 0, 0^3 = 0,

%e 1^2 = 1, 1^3 = 1,

%e 2^2 = 10, 2^3 = 20,

%e 3^2 = 21, 3^3 = 123.

%e Three of these pairs have the same final digit, so a(4)=3.

%t Table[Count[Range@ n, _?(PowerMod[#, 2, n] == PowerMod[#, 3, n] &)], {n, 85}] (* _Michael De Vlieger_, Jul 30 2018 *)

%t f[p_, e_] := p^Floor[e/2] + 1; a[n_] := Times @@ f @@@ FactorInteger[n]; a[1] = 1; Array[a, 100] (* _Amiram Eldar_, Sep 07 2023 *)

%o (Python) #

%o for base in range(1,101):

%o ....n = 0

%o ....for j in range(base):

%o ........if (j**2)%base == (j**3)%base:

%o ............n += 1

%o ....print(base,n)

%o (Haskell)

%o a305461 n = length $ filter (\i -> (i^3 - i^2) `mod` n == 0) [0..n-1]

%o -- _Peter Kagey_, Jun 10 2018

%o (PARI) a(n) = sum(k=0, n-1, mk = Mod(k, n); mk^2 == mk^3); \\ _Michel Marcus_, Jul 03 2018

%o (PARI) a(n)={my(f=factor(n)); prod(i=1, #f~, my(p=f[i,1], e=f[i,2]); p^(e\2) + 1)} \\ _Andrew Howroyd_, Jul 22 2018

%Y A034444 is the number of one-digit numbers, k, in base n such that k and k^2 end in the same digit.

%Y Cf. A230542.

%K nonn,easy,mult

%O 1,2

%A _Matthew Scroggs_, Jun 01 2018

%E a(1) inserted by _Andrew Howroyd_, Jul 22 2018