login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A052423 Highest common factor of nonzero digits of n. 6

%I #18 Apr 04 2020 16:44:03

%S 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,

%T 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,

%U 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

%N Highest common factor of nonzero digits of n.

%H Reinhard Zumkeller, <a href="/A052423/b052423.txt">Table of n, a(n) for n = 1..10000</a>

%F a(A069715(n)) = 1. - _Reinhard Zumkeller_, Apr 14 2014

%e a(46) = 2 because the highest common factor of 4 and 6 is 2.

%e a(47) = 1 because the highest common factor of 4 and 7 is 1.

%p a:= n-> igcd(subs(0=[][], convert(n, base, 10))[]):

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Apr 04 2020

%t Table[Apply[GCD, IntegerDigits[n]], {n, 100}] (* _Alonso del Arte_, Apr 02 2020 *)

%o (Haskell)

%o a052423 n = f n n where

%o f x 1 = 1

%o f x y | x < 10 = gcd x y

%o | otherwise = if d == 1 then 1 else f x' (gcd d y)

%o where (x', d) = divMod x 10

%o -- _Reinhard Zumkeller_, Apr 14 2014

%o (Scala) def euclGCD(a: Int, b: Int): Int = b match { case 0 => a; case n => Math.abs(euclGCD(b, a % b)) }

%o def digitGCD(n: Int) = n.toString.toCharArray.map(_ - 48).scanLeft(0)(euclGCD(_, _)).last

%o (1 to 100).map(digitGCD(_)) // _Alonso del Arte_, Apr 02 2020

%o (PARI) a(n) = my(d=digits(n)); gcd(select(x->(x!=0), d)); \\ _Michel Marcus_, Apr 04 2020

%Y Cf. A007954.

%K base,easy,nonn

%O 1,2

%A _Henry Bottomley_, Mar 17 2000

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 15:20 EDT 2024. Contains 371916 sequences. (Running on oeis4.)