A365762 Greatest common divisor of n and the product of its digits.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 1, 2, 5, 2, 1, 2, 1, 20, 1, 2, 1, 8, 5, 2, 1, 4, 1, 30, 1, 2, 3, 2, 5, 18, 1, 2, 3, 40, 1, 2, 1, 4, 5, 2, 1, 16, 1, 50, 1, 2, 1, 2, 5, 2, 1, 2, 1, 60, 1, 2, 9, 8, 5, 6, 1, 4, 3, 70, 1, 2, 1, 2, 5, 2, 7, 2, 1, 80, 1, 2, 1, 4, 5, 2, 1, 8, 1, 90, 1, 2, 3, 2, 5, 6, 1, 2, 9, 100
Offset: 1
Examples
a(11)=1 as 1*1=1; 11 and 1 share 1 as a gcd. a(15)=5 as 1*5=5; 15 and 5 share 5 as a gcd. a(10)=10 as 1*0=0; 10 and 0 share 10 as a gcd.
Programs
-
Mathematica
a[n_]:=GCD[n,Product[Part[IntegerDigits[n],i],{i,IntegerLength[n]}]]; Array[a,100] (* Stefano Spezia, Sep 20 2023 *)
-
PARI
a(n) = gcd(n, vecprod(digits(n))); \\ Michel Marcus, Sep 20 2023
-
Python
from math import gcd, prod def a(n): return gcd(n, prod(map(int, str(n)))) print([a(n) for n in range(1, 101)])
Comments