cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A055483 a(n) is the GCD of n and the reverse of n.

Original entry on oeis.org

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, 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, 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
Offset: 1

Views

Author

Erich Friedman, Jun 27 2000

Keywords

Comments

a(A226778(n)) = 1; a(A071249(n)) > 1. - Reinhard Zumkeller, Jun 18 2013
a(n) = n iff n >= 1 is a palindrome (n is in A002113). - Felix Fröhlich, Oct 28 2014

Examples

			a(12) = 3 since gcd(12, 21) = 3.
a(13) = 1 since 13 and 31 are coprime.
a(101) = gcd(101, 101) = 101.
		

Crossrefs

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

Programs

  • Haskell
    a055483 n = gcd n $ a004086 n  -- Reinhard Zumkeller, Jun 18 2013
    
  • Magma
    [Gcd(n, Seqint(Reverse(Intseq(n)))): n in [1..100]]; // Vincenzo Librandi, Oct 29 2014
    
  • Mathematica
    gcn[n_] := GCD[n, IntegerReverse[n]]; Array[gcn, 120] (* Harvey P. Dale, Jan 23 2012 *)
  • PARI
    a004086(n)=eval(concat(Vecrev(Str(n))))
    a(n)=gcd(n, a004086(n)) \\ Felix Fröhlich, Oct 28 2014
    
  • 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
  • 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
    

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

Extensions

Edited by Robert G. Wilson v, Apr 10 2002