OFFSET
1,2
COMMENTS
a(n) = n iff n >= 1 is a palindrome (n is in A002113). - Felix Fröhlich, Oct 28 2014
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..50000 (first 1000 terms from T. D. Noe)
FORMULA
a(n) = gcd(n, A004086(n)). - Felix Fröhlich, Oct 28 2014
3 | a(n) if 3 | n and 9 | a(n) if 9 | n. - Alonso del Arte, Aug 31 2021
EXAMPLE
a(12) = 3 since gcd(12, 21) = 3.
a(13) = 1 since 13 and 31 are coprime.
a(101) = gcd(101, 101) = 101.
MATHEMATICA
gcn[n_] := GCD[n, IntegerReverse[n]]; Array[gcn, 120] (* Harvey P. Dale, Jan 23 2012 *)
PROG
(Haskell)
a055483 n = gcd n $ a004086 n -- Reinhard Zumkeller, Jun 18 2013
(PARI) a004086(n)=eval(concat(Vecrev(Str(n))))
a(n)=gcd(n, a004086(n)) \\ Felix Fröhlich, Oct 28 2014
(Magma) [Gcd(n, Seqint(Reverse(Intseq(n)))): n in [1..100]]; // Vincenzo Librandi, Oct 29 2014
(Scala) def reverseDigits(n: Int): Int = Integer.parseInt(n.toString.reverse)
def euclGCD(a: Int, b: Int): Int = b match { case 0 => a; case n => Math.abs(euclGCD(b, a % b)) }
(1 to 120).map(n => euclGCD(n, reverseDigits(n))) // Alonso del Arte, Aug 31 2021
(Python)
from math import gcd
def a(n): return gcd(n, int(str(n)[::-1]))
print([a(n) for n in range(1, 112)]) # Michael S. Branicky, Aug 31 2021
CROSSREFS
KEYWORD
base,easy,nonn,nice
AUTHOR
Erich Friedman, Jun 27 2000
EXTENSIONS
Edited by Robert G. Wilson v, Apr 10 2002
STATUS
approved