login
a(n) is the GCD of n and the reverse of n.
22

%I #62 Feb 19 2024 01:58:47

%S 1,2,3,4,5,6,7,8,9,1,11,3,1,1,3,1,1,9,1,2,3,22,1,6,1,2,9,2,1,3,1,1,33,

%T 1,1,9,1,1,3,4,1,6,1,44,9,2,1,12,1,5,3,1,1,9,55,1,3,1,1,6,1,2,9,2,1,

%U 66,1,2,3,7,1,9,1,1,3,1,77,3,1,8,9,2,1,12,1,2,3,88,1,9,1,1,3,1,1,3,1,1,99,1,101,3,1,1,3,1,1,9,1,11,111

%N a(n) is the GCD of n and the reverse of n.

%C a(A226778(n)) = 1; a(A071249(n)) > 1. - _Reinhard Zumkeller_, Jun 18 2013

%C a(n) = n iff n >= 1 is a palindrome (n is in A002113). - _Felix Fröhlich_, Oct 28 2014

%H Indranil Ghosh, <a href="/A055483/b055483.txt">Table of n, a(n) for n = 1..50000</a> (first 1000 terms from T. D. Noe)

%F a(n) = gcd(n, A004086(n)). - _Felix Fröhlich_, Oct 28 2014

%F 3 | a(n) if 3 | n and 9 | a(n) if 9 | n. - _Alonso del Arte_, Aug 31 2021

%e a(12) = 3 since gcd(12, 21) = 3.

%e a(13) = 1 since 13 and 31 are coprime.

%e a(101) = gcd(101, 101) = 101.

%t gcn[n_] := GCD[n, IntegerReverse[n]]; Array[gcn, 120] (* _Harvey P. Dale_, Jan 23 2012 *)

%o (Haskell)

%o a055483 n = gcd n $ a004086 n -- _Reinhard Zumkeller_, Jun 18 2013

%o (PARI) a004086(n)=eval(concat(Vecrev(Str(n))))

%o a(n)=gcd(n, a004086(n)) \\ _Felix Fröhlich_, Oct 28 2014

%o (Magma) [Gcd(n, Seqint(Reverse(Intseq(n)))): n in [1..100]]; // _Vincenzo Librandi_, Oct 29 2014

%o (Scala) def reverseDigits(n: Int): Int = Integer.parseInt(n.toString.reverse)

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

%o (1 to 120).map(n => euclGCD(n, reverseDigits(n))) // _Alonso del Arte_, Aug 31 2021

%o (Python)

%o from math import gcd

%o def a(n): return gcd(n, int(str(n)[::-1]))

%o print([a(n) for n in range(1, 112)]) # _Michael S. Branicky_, Aug 31 2021

%Y Different from A069652, first differs at a(101), since gcd(101, 110) = 1.

%Y Cf. A002113, A004086, A071249, A226778.

%K base,easy,nonn,nice

%O 1,2

%A _Erich Friedman_, Jun 27 2000

%E Edited by _Robert G. Wilson v_, Apr 10 2002