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.

Showing 1-2 of 2 results.

A028897 If n = Sum c_i 10^i then a(n) = Sum c_i 2^i.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 4
Offset: 0

Views

Author

Keywords

Comments

For n<100, this is the same result as "If n = Sum c_i 10^i then a(n) = Sum c_i (i+1)". - Henry Bottomley, Apr 20 2001
n_2 in the notation of A122618.
Left inverse of A007088 (binary numbers), cf. formula from Karttunen. - M. F. Hasler, Jun 13 2023

Crossrefs

Differs from A081594 and A244158 for the first time at n = 100, which here is a(100) = 4.
See A322000 for integers ordered according to the value of a(n).

Programs

  • Haskell
    a028897 0 = 0
    a028897 n = 2 * a028897 n' + d where (n', d) = divMod n 10
    -- Reinhard Zumkeller, Nov 06 2014
  • Mathematica
    a[n_ /; n < 10] := n; a[n_] := a[n] = If[Mod[n, 10] != 0, a[n-1] + 1, 2*a[n/10]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Apr 02 2016 *)
  • PARI
    a(n)=if(n<1,0,if(n%10,a(n-1)+1,2*a(n/10)))
    
  • PARI
    A028897(n)=fromdigits(digits(n),2) \\ M. F. Hasler, Feb 14 2019
    (MIT/GNU Scheme) (define (A028897 n) (let loop ((z 0) (i 0) (n n)) (if (zero? n) z (loop (+ z (* (modulo n 10) (expt 2 i))) (1+ i) (floor->exact (/ n 10)))))) ;; Antti Karttunen, Jun 22 2014
    

Formula

a(n) = 2*a(floor(n/10)) + (n mod 10). - Henry Bottomley, Apr 20 2001
a(0) = 0, a(n) = 2*a(n/10) if n == 0 (mod 10), a(n) = a(n-1)+1 otherwise. - Benoit Cloitre, Dec 21 2002
For all n, a(A007088(n)) = n. - Antti Karttunen, Jun 22 2014

Extensions

More terms from Erich Friedman.
Terms up to n = 100 added by Antti Karttunen, Jun 22 2014

A093017 Luhn algorithm double-and-add sum of digits of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 7, 8, 9, 10, 11, 12, 13
Offset: 0

Views

Author

Ray Chandler, Apr 03 2004

Keywords

Comments

Starting on the right, sum digits after doubling alternating digits beginning with the second. If doubled digit >9, reduce by 9 (sum of digits).
a(n) = A007953(A249873(n)); A093019(n) = 10 - a(10*n) mod 10 if less than 10, otherwise 0. - Reinhard Zumkeller, Nov 08 2014
First differences are b(n) defined for n>0 as follows. Take the prime factorization of n and let x be the number of 2's, y be the number of 5's, and z be min(x,y). If z is even, b(n) = 1 - 9*z. If z is odd and y=z, b(n) = 2 - 9*z. If z is odd and y>z, b(n) = -7 - 9*z. Now a(n) = a(n-1) + b(n). - Mathew Englander, Aug 04 2021

Examples

			a(18) = 2*1 + 8 = 10.
a(59) = (1+0) + 9 = 10 (1 and 0 are the digits in 10 = 2*5).
		

Crossrefs

Programs

  • Haskell
    a093017 n = if n == 0 then 0 else a093017 n' + a007953 (2 * t) + d
                where (n', td) = divMod n 100; (t, d) = divMod td 10
    -- Reinhard Zumkeller, Nov 08 2014
    
  • Python
    def a(n):
        s = str(n)
        r = s[::-1]
        x = sum(int(d) for d in r[::2])
        x += sum(q if (q:=2*int(d)) < 10 else q-9 for d in r[1::2])
        return x
    print([a(n) for n in range(87)]) # Michael S. Branicky, Jul 23 2024

Formula

a(0)=0; for n not divisible by 10, a(n)=1+a(n-1); for n divisible by 10 but not 50, a(n)=2+a(n-10); for n divisible by 50 but not 100, a(n)=1+a(n-50); for n divisible by 100, a(n)=a(n/100). - Mathew Englander, Aug 04 2021
Showing 1-2 of 2 results.