login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A052423
Highest common factor of nonzero digits of n.
7
1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 1, 3, 1, 1, 3, 1, 1, 3, 4, 1, 2, 1, 4, 1, 2, 1, 4, 1, 5, 1, 1, 1, 1, 5, 1, 1, 1, 1, 6, 1, 2, 3, 2, 1, 6, 1, 2, 3, 7, 1, 1, 1, 1, 1, 1, 7, 1, 1, 8, 1, 2, 1, 4, 1, 2, 1, 8, 1, 9, 1, 1, 3, 1, 1, 3, 1, 1, 9, 1, 1, 1
OFFSET
1,2
LINKS
FORMULA
a(A069715(n)) = 1. - Reinhard Zumkeller, Apr 14 2014
EXAMPLE
a(46) = 2 because the highest common factor of 4 and 6 is 2.
a(47) = 1 because the highest common factor of 4 and 7 is 1.
MAPLE
a:= n-> igcd(subs(0=[][], convert(n, base, 10))[]):
seq(a(n), n=1..100); # Alois P. Heinz, Apr 04 2020
MATHEMATICA
Table[Apply[GCD, IntegerDigits[n]], {n, 100}] (* Alonso del Arte, Apr 02 2020 *)
PROG
(Haskell)
a052423 n = f n n where
f x 1 = 1
f x y | x < 10 = gcd x y
| otherwise = if d == 1 then 1 else f x' (gcd d y)
where (x', d) = divMod x 10
-- Reinhard Zumkeller, Apr 14 2014
(Scala) def euclGCD(a: Int, b: Int): Int = b match { case 0 => a; case n => Math.abs(euclGCD(b, a % b)) }
def digitGCD(n: Int) = n.toString.toCharArray.map(_ - 48).scanLeft(0)(euclGCD(_, _)).last
(1 to 100).map(digitGCD(_)) // Alonso del Arte, Apr 02 2020
(PARI) a(n) = my(d=digits(n)); gcd(select(x->(x!=0), d)); \\ Michel Marcus, Apr 04 2020
CROSSREFS
Cf. A007954.
Sequence in context: A075877 A133500 A256229 * A126616 A121042 A369529
KEYWORD
base,easy,nonn
AUTHOR
Henry Bottomley, Mar 17 2000
STATUS
approved