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-10 of 12 results. Next

A128983 Rightmost position of n in A089625, 0 if absent.

Original entry on oeis.org

0, 1, 2, 0, 4, 0, 8, 6, 9, 10, 16, 12, 32, 18, 33, 34, 64, 36, 128, 66, 129, 130, 256, 132, 257, 258, 134, 260, 512, 264, 1024, 514, 1025, 1026, 268, 1028, 2048, 1032, 2049, 2050, 4096
Offset: 1

Views

Author

R. J. Mathar, Apr 30 2007

Keywords

Comments

Numbers n have A000586(n) decompositions into sums of distinct primes and occur A000586(n) times in A089625. The sequence is the rightmost (largest) index (position) of n in A089625. It is an inverse of A089625 made unique in the sense that in the prime decomposition of n the one with the largest primes are chosen and converted to binary. The sequence therefore is a binary representation of a greedy decomposition of n into a sum of primes.

Examples

			Prime decompositions of n=25 are 1*11+1*7+1*5+0*3+1*2 (binary tagged 11101=29)
or 1*13+0*11+1*7+0*5+1*3+1*2 (binary 101011=43) or
1*13+0*11+1*7+1*5+0*3+0*2 (binary 101100=44) or 1*17+0*13+0*11+0*7+1*5+1*3+0*2
(binary 1000110=70) or 1*23+0*19+0*17+0*13+0*11+0*7+0*5+0*3+1*2 (binary 100000001
=257). Out of these indices 29, 43, 44, 70 and 257, the largest is chosen, a(25)=257.
		

Crossrefs

Formula

A089625(a(n))=n if n not equal to 1, 4 and 6.

A029931 If 2n = Sum 2^e_i, a(n) = Sum e_i.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Write n in base 2, n = sum b(i)*2^(i-1), then a(n) = sum b(i)*i. - Benoit Cloitre, Jun 09 2002
May be regarded as a triangular array read by rows, giving weighted sum of compositions in standard order. The standard order of compositions is given by A066099. - Franklin T. Adams-Watters, Nov 06 2006
Sum of all positive integer roots m_i of polynomial {m,k} - see link [Shevelev]; see also A264613. - Vladimir Shevelev, Dec 13 2015
Also the sum of binary indices of n, where a binary index of n (A048793) is any position of a 1 in its reversed binary expansion. For example, the binary indices of 11 are {1,2,4}, so a(11) = 7. - Gus Wiseman, May 22 2024

Examples

			14 = 8+4+2 so a(7) = 3+2+1 = 6.
Composition number 11 is 2,1,1; 1*2+2*1+3*1 = 7, so a(11) = 7.
The triangle starts:
  0
  1
  2 3
  3 4 5 6
The reversed binary expansion of 18 is (0,1,0,0,1) with 1's at positions {2,5}, so a(18) = 2 + 5 = 7. - _Gus Wiseman_, Jul 22 2019
		

Crossrefs

Other sequences that are built by replacing 2^k in the binary representation with other numbers: A022290 (Fibonacci), A059590 (factorials), A073642, A089625 (primes), A116549, A326031.
Cf. A001793 (row sums), A011782 (row lengths), A059867, A066099, A124757.
Row sums of A048793 and A272020.
Contains exactly A000009(n) copies of n.
For length instead of sum we have A000120, complement A023416.
For minimum instead of sum we have A001511, opposite A000012.
For maximum instead of sum we have A029837 or A070939, opposite A070940.
For product instead of sum we have A096111.
The reverse version is A230877, row sums of A371572.
The reverse complement is A359359, row sums of A371571.
The complement is A359400, row sums of A368494.
Numbers k such that a(k) is prime are A372689.
A014499 lists binary indices of prime numbers.
A019565 gives Heinz number of binary indices, inverse A048675.
A372471 lists binary indices of primes, row-sums A372429.

Programs

  • Haskell
    a029931 = sum . zipWith (*) [1..] . a030308_row
    -- Reinhard Zumkeller, Feb 28 2014
    
  • Maple
    HammingWeight := n -> add(i, i = convert(n, base, 2)):
    a := proc(n) option remember; `if`(n = 0, 0,
    ifelse(n::even, a(n/2) + HammingWeight(n/2), a(n-1) + 1)) end:
    seq(a(n), n = 0..78); # Peter Luschny, Oct 30 2021
  • Mathematica
    a[n_] := (b = IntegerDigits[n, 2]).Reverse @ Range[Length @ b]; Array[a,78,0] (* Jean-François Alcover, Apr 28 2011, after B. Cloitre *)
  • PARI
    for(n=0,100,l=length(binary(n)); print1(sum(i=1,l, component(binary(n),i)*(l-i+1)),","))
    
  • PARI
    a(n) = my(b=binary(n)); b*-[-#b..-1]~; \\ Ruud H.G. van Tol, Oct 17 2023
    
  • Python
    def A029931(n): return sum(i if j == '1' else 0 for i, j in enumerate(bin(n)[:1:-1],1)) # Chai Wah Wu, Dec 20 2022
    (C#)
    ulong A029931(ulong n) {
        ulong result = 0, counter = 1;
        while(n > 0) {
            if (n % 2 == 1)
              result += counter;
            counter++;
            n /= 2;
        }
        return result;
    } // Frank Hollstein, Jan 07 2023

Formula

a(n) = a(n - 2^L(n)) + L(n) + 1 [where L(n) = floor(log_2(n)) = A000523(n)] = sum of digits of A048794 [at least for n < 512]. - Henry Bottomley, Mar 09 2001
a(0) = 0, a(2n) = a(n) + e1(n), a(2n+1) = a(2n) + 1, where e1(n) = A000120(n). a(n) = log_2(A029930(n)). - Ralf Stephan, Jun 19 2003
G.f.: (1/(1-x)) * Sum_{k>=0} (k+1)*x^2^k/(1+x^2^k). - Ralf Stephan, Jun 23 2003
a(n) = Sum_{k>=0} A030308(n,k)*A000027(k+1). - Philippe Deléham, Oct 15 2011
a(n) = sum of n-th row of the triangle in A213629. - Reinhard Zumkeller, Jun 17 2012
From Reinhard Zumkeller, Feb 28 2014: (Start)
a(A089633(n)) = n and a(m) != n for m < A089633(n).
a(n) = Sum_{k=1..A070939(n)} k*A030308(n,k-1). (End)
a(n) = A073642(n) + A000120(n). - Peter Kagey, Apr 04 2016

Extensions

More terms from Erich Friedman

A059590 Numbers obtained by reinterpreting base-2 representation of n in the factorial base: a(n) = Sum_{k>=0} A030308(n,k)*A000142(k+1).

Original entry on oeis.org

0, 1, 2, 3, 6, 7, 8, 9, 24, 25, 26, 27, 30, 31, 32, 33, 120, 121, 122, 123, 126, 127, 128, 129, 144, 145, 146, 147, 150, 151, 152, 153, 720, 721, 722, 723, 726, 727, 728, 729, 744, 745, 746, 747, 750, 751, 752, 753, 840, 841, 842, 843, 846, 847, 848, 849, 864, 865
Offset: 0

Views

Author

Henry Bottomley, Jan 24 2001

Keywords

Comments

Numbers that are sums of distinct factorials (0! and 1! not treated as distinct).
Complement of A115945; A115944(a(n)) > 0; A115647 is a subsequence. - Reinhard Zumkeller, Feb 02 2006
A115944(a(n)) = 1. - Reinhard Zumkeller, Dec 04 2011
From Tilman Piesk, Jun 04 2012: (Start)
The inversion vector (compare A007623) of finite permutation a(n) (compare A055089, A195663) has only zeros and ones. Interpreted as a binary number it is 2*n (or n when the inversion vector is defined without the leading 0).
The inversion set of finite permutation a(n) interpreted as a binary number (compare A211362) is A211364(n).
(End)

Examples

			128 is in the sequence since 5! + 3! + 2! = 128.
a(22) = 128. a(22) = a(6) + (1 + floor(log(16) / log(2)))! = 8 + 5! = 128. Also, 22 = 10110_2. Therefore, a(22) = 1 * 5! + 0 * 4! + 1 * 3! + 1 + 2! + 0 * 0! = 128. - _David A. Corneth_, Aug 21 2016
		

Crossrefs

Indices of zeros in A257684.
Cf. A275736 (left inverse).
Cf. A025494, A060112 (subsequences).
Subsequence of A060132, A256450 and A275804.
Other sequences that are built by replacing 2^k in the binary representation with other numbers: A029931 (naturals), A089625 (primes), A022290 (Fibonacci), A197433 (Catalans), A276091 (n*n!), A275959 ((2n)!/2). Cf. also A276082 & A276083.

Programs

  • Haskell
    import Data.List (elemIndices)
    a059590 n = a059590_list !! n
    a059590_list = elemIndices 1 $ map a115944 [0..]
    -- Reinhard Zumkeller, Dec 04 2011
    
  • Maple
    [seq(bin2facbase(j),j=0..64)]; bin2facbase := proc(n) local i; add((floor(n/(2^i)) mod 2)*((i+1)!),i=0..floor_log_2(n)); end;
    floor_log_2 := proc(n) local nn,i; nn := n; for i from -1 to n do if(0 = nn) then RETURN(i); fi; nn := floor(nn/2); od; end;
    # next Maple program:
    a:= n-> (l-> add(l[j]*j!, j=1..nops(l)))(Bits[Split](n)):
    seq(a(n), n=0..57);  # Alois P. Heinz, Aug 12 2025
  • Mathematica
    a[n_] :=  Reverse[id = IntegerDigits[n, 2]].Range[Length[id]]!; Table[a[n], {n, 0, 60}] (* Jean-François Alcover, Jun 19 2012, after Philippe Deléham *)
  • PARI
    a(n) = if(n>0, a(n-msb(n)) + (1+logint(n,2))!, 0)
    msb(n) = 2^#binary(n)>>1
    {my(b = binary(n)); sum(i=1,#b,b[i]*(#b+1-i)!)} \\ David A. Corneth, Aug 21 2016
    
  • Python
    def facbase(k, f):
        return sum(f[i] for i, bi in enumerate(bin(k)[2:][::-1]) if bi == "1")
    def auptoN(N): # terms up to N factorial-base digits; 13 generates b-file
        f = [factorial(i) for i in range(1, N+1)]
        return list(facbase(k, f) for k in range(2**N))
    print(auptoN(5)) # Michael S. Branicky, Oct 15 2022

Formula

G.f. 1/(1-x) * Sum_{k>=0} (k+1)!*x^2^k/(1+x^2^k). - Ralf Stephan, Jun 24 2003
a(n) = Sum_{k>=0} A030308(n,k)*A000142(k+1). - Philippe Deléham, Oct 15 2011
From Antti Karttunen, Aug 19 2016: (Start)
a(0) = 0, a(2n) = A153880(a(n)), a(2n+1) = 1+A153880(a(n)).
a(n) = A225901(A276091(n)).
a(n) = A276075(A019565(n)).
a(A275727(n)) = A276008(n).
A275736(a(n)) = n.
A276076(a(n)) = A019565(n).
A007623(a(n)) = A007088(n).
(End)
a(n) = a(n - mbs(n)) + (1 + floor(log(n) / log(2)))!. - David A. Corneth, Aug 21 2016

Extensions

Name changed (to emphasize the functional nature of the sequence) with the old definition moved to the comments by Antti Karttunen, Aug 21 2016

A022290 Replace 2^k in binary expansion of n with Fibonacci(k+2).

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			n=4 = 2^2 is replaced by A000045(2+2) = 3. n=5 = 2^2 + 2^0 is replaced by A000045(2+2) + A000045(0+2) = 3+1 = 4. - _R. J. Mathar_, Jan 31 2015
From _Philippe Deléham_, Jun 05 2015: (Start)
This sequence regarded as a triangle with rows of lengths 1, 1, 2, 4, 8, 16, ...:
  0
  1
  2, 3
  3, 4, 5, 6
  5, 6, 7, 8, 8, 9, 10, 11
  8, 9, 10, 11, 11, 12, 13, 14, 13, 14, 15, 16, 16, 17, 18, 19
  ...
(End)
		

Crossrefs

Other sequences that are built by replacing 2^k in the binary representation with other numbers: A029931 (naturals), A054204 (even-indexed Fibonacci numbers), A062877 (odd-indexed Fibonacci numbers), A059590 (factorials), A089625 (primes).

Programs

  • Haskell
    a022290 0 = 0
    a022290 n = h n 0 $ drop 2 a000045_list where
       h 0 y _      = y
       h x y (f:fs) = h x' (y + f * r) fs where (x',r) = divMod x 2
    -- Reinhard Zumkeller, Oct 03 2012
    
  • Maple
    A022290 := proc(n)
        dgs := convert(n,base,2) ;
        add( op(i,dgs)*A000045(i+1),i=1..nops(dgs)) ;
    end proc: # R. J. Mathar, Jan 31 2015
    # second Maple program:
    b:= (n, i, j)-> `if`(n=0, 0, j*irem(n, 2, 'q')+b(q, j, i+j)):
    a:= n-> b(n, 1$2):
    seq(a(n), n=0..127);  # Alois P. Heinz, Jan 26 2022
  • Mathematica
    Table[Reverse[#].Fibonacci[1 + Range[Length[#]]] &@ IntegerDigits[n, 2], {n, 0, 54}] (* IWABUCHI Yu(u)ki, Aug 01 2012 *)
  • PARI
    my(m=Mod('x,'x^2-'x-1)); a(n) = subst(lift(subst(Pol(binary(n)), 'x,m)), 'x,2); \\ Kevin Ryde, Sep 22 2020
    
  • Python
    def A022290(n):
        a, b, s = 1,2,0
        for i in bin(n)[-1:1:-1]:
            s += int(i)*a
            a, b = b, a+b
        return s # Chai Wah Wu, Sep 10 2022

Formula

G.f.: (1/(1-x)) * Sum_{k>=0} F(k+2)*x^2^k/(1+x^2^k), where F = A000045.
a(n) = Sum_{k>=0} A030308(n,k)*A000045(k+2). - Philippe Deléham, Oct 15 2011
a(A003714(n)) = n. - R. J. Mathar, Jan 31 2015
a(A000225(n)) = A001911(n). - Philippe Deléham, Jun 05 2015
From Jeffrey Shallit, Jul 17 2018: (Start)
Can be computed from the recurrence:
a(4*k) = a(k) + a(2*k),
a(4*k+1) = a(k) + a(2*k+1),
a(4*k+2) = a(k) - a(2*k) + 2*a(2*k+1),
a(4*k+3) = a(k) - 2*a(2*k) + 3*a(2*k+1),
and the initial terms a(0) = 0, a(1) = 1. (End)
a(A003754(n)) = n-1. - Rémy Sigrist, Jan 28 2020
From Rémy Sigrist, Aug 04 2022: (Start)
Empirically:
- a(2*A003714(n)) = A022342(n+1),
- a(3*A003714(n)) = a(4*A003714(n)) = A026274(n) for n > 0.
(End)

A197433 Sum of distinct Catalan numbers: a(n) = Sum_{k>=0} A030308(n,k)*C(k+1) where C(n) is the n-th Catalan number (A000108). (C(0) and C(1) not treated as distinct.)

Original entry on oeis.org

0, 1, 2, 3, 5, 6, 7, 8, 14, 15, 16, 17, 19, 20, 21, 22, 42, 43, 44, 45, 47, 48, 49, 50, 56, 57, 58, 59, 61, 62, 63, 64, 132, 133, 134, 135, 137, 138, 139, 140, 146, 147, 148, 149, 151, 152, 153, 154, 174, 175, 176, 177, 179, 180, 181, 182, 188, 189, 190, 191, 193, 194, 195, 196
Offset: 0

Views

Author

Philippe Deléham, Oct 15 2011

Keywords

Comments

Replace 2^k with A000108(k+1) in binary expansion of n.
From Antti Karttunen, Jun 22 2014: (Start)
On the other hand, A244158 is similar, but replaces 10^k with A000108(k+1) in decimal expansion of n.
This sequence gives all k such that A014418(k) = A239903(k), which are precisely all nonnegative integers k whose representations in those two number systems contain no digits larger than 1. From this also follows that this is a subsequence of A244155.
(End)

Crossrefs

Characteristic function: A176137.
Subsequence of A244155.
Cf. also A060112.
Other sequences that are built by replacing 2^k in binary representation with other numbers: A022290 (Fibonacci), A029931 (natural numbers), A059590 (factorials), A089625 (primes), A197354 (odd numbers).

Programs

  • Mathematica
    nmax = 63;
    a[n_] := If[n == 0, 0, SeriesCoefficient[(1/(1-x))*Sum[CatalanNumber[k+1]* x^(2^k)/(1 + x^(2^k)), {k, 0, Log[2, n] // Ceiling}], {x, 0, n}]];
    Table[a[n], {n, 0, nmax}] (* Jean-François Alcover, Nov 18 2021, after Ilya Gutkovskiy *)

Formula

For all n, A244230(a(n)) = n. - Antti Karttunen, Jul 18 2014
G.f.: (1/(1 - x))*Sum_{k>=0} Catalan number(k+1)*x^(2^k)/(1 + x^(2^k)). - Ilya Gutkovskiy, Jul 23 2017

Extensions

Name clarified by Antti Karttunen, Jul 18 2014

A178344 a(n) = Sum_i prime(i+1)^b(i) where n = Sum_{i>=0} b(i)*2^e(i) is the binary representation of n.

Original entry on oeis.org

1, 2, 4, 5, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 15, 16, 17, 18, 19, 20, 21, 22, 21, 22, 23, 24, 25, 26, 27, 28, 18, 19, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 30, 31, 28, 29, 30, 31, 32, 33, 34, 35, 34, 35, 36, 37, 38, 39, 40, 41, 23, 24, 25, 26, 27, 28, 29, 30, 29, 30
Offset: 0

Views

Author

Juri-Stepan Gerasimov, May 25 2010, Jan 06 2010

Keywords

Comments

a(0) = 0 might be a more logical value for the initial term. - Antti Karttunen, Sep 28 2018

Examples

			a(16)=15 because 10000 is the base-2 representation of n=16 and 11^1 + 7^0 + 5^0 + 3^0 + 2^0 = 15.
		

Crossrefs

Cf. A178562 (first differences).

Programs

  • Maple
    A178344 := proc(n)
        if n = 0 then
            dgs := [0] ;
        else
            dgs := convert(n,base,2) ;
        end if;
        add(ithprime(i)^dgs[i],i=1..nops(dgs)) ;
    end proc:
    seq(A178344(n),n=0..73) ; # R. J. Mathar, Sep 28 2018
  • Mathematica
    Array[Total@ MapIndexed[Prime[First@ #2]^#1 &, Reverse@ IntegerDigits[#, 2]] &, 74, 0] (* Michael De Vlieger, Feb 19 2019 *)
  • PARI
    a(n) = my(b=Vecrev(binary(n))); if (n==0, b=[0]); sum(i=1, #b, prime(i)^b[i]); \\ Michel Marcus, Sep 29 2018

Formula

For n >= 1, a(n) = A089625(n) + A080791(n). - Antti Karttunen, Sep 28 2018

Extensions

Offset modified, keyword:base added by R. J. Mathar, May 28 2010

A197354 a(n) = Sum_{k>=0} A030308(n,k)*(2k+1).

Original entry on oeis.org

0, 1, 3, 4, 5, 6, 8, 9, 7, 8, 10, 11, 12, 13, 15, 16, 9, 10, 12, 13, 14, 15, 17, 18, 16, 17, 19, 20, 21, 22, 24, 25, 11, 12, 14, 15, 16, 17, 19, 20, 18, 19, 21, 22, 23, 24, 26, 27, 20, 21, 23, 24, 25, 26, 28, 29, 27, 28, 30, 31, 32, 33, 35, 36, 13, 14, 16
Offset: 0

Views

Author

Philippe Deléham, Oct 14 2011

Keywords

Comments

For any k >= 0, A000700(k) equals the number of occurrences of k in the sequence. - Rémy Sigrist, Jan 19 2019

Crossrefs

Other sequences that are built by replacing 2^k in the binary representation with other numbers: A022290 (Fibonacci), A029931 (natural numbers), A059590 (factorials), A089625 (primes).

Programs

  • PARI
    a(n) = my (b=Vecrev(binary(n))); sum(i=1, #b, if (b[i], 2*i-1, 0)) \\ Rémy Sigrist, Jan 19 2019

Formula

a(2^n-1) = n^2.
a(n) mod 2 = A010060(n).
G.f.: (1/(1 - x))*Sum_{k>=0} (2*k + 1)*x^(2^k)/(1 + x^(2^k)). - Ilya Gutkovskiy, Jul 23 2017

A331835 Replace 2^k in binary expansion of n with k-th prime number for any k > 0 (and keep 2^0).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jan 28 2020

Keywords

Comments

Every nonnegative integer appears in this sequence as A008578 is a complete sequence.
For any m >= 0, m appears A036497(m) times, the first and last occurrences being at indices A345297(m) and A200947(m), respectively. - Rémy Sigrist, Jun 13 2021

Examples

			For n = 43:
- 43 = 2^0 + 2^1 + 2^3 + 2^5,
- so a(43) = 2^0 + prime(1) + prime(3) + prime(5) = 1 + 2 + 5 + 11 = 19.
		

Crossrefs

Programs

  • Mathematica
    Array[Total@ Map[If[# == 0, 1, Prime[#]] &, Position[Reverse@ IntegerDigits[#, 2], 1][[All, 1]] - 1] &, 68] (* Michael De Vlieger, Jan 29 2020 *)
  • PARI
    a(n) = my (b=Vecrev(binary(n\2))); n%2 + sum(k=1, #b, if (b[k], prime(k), 0))
    
  • Python
    from sympy import prime
    def p(n): return prime(n) if n >= 1 else 1
    def a(n): return sum(p(i)*int(b) for i, b in enumerate(bin(n)[:1:-1]))
    print([a(n) for n in range(69)]) # Michael S. Branicky, Jun 13 2021

Formula

a(2*n) = A089625(n) for any n > 0.
a(2*n+1) = A089625(n) + 1 for any n > 0.
G.f.: x/(1 - x^2) + (1/(1 - x)) * Sum_{k>=1} prime(k) * x^(2^k) / (1 + x^(2^k)). - Ilya Gutkovskiy, May 24 2024

A262478 a(n) = Sum_{i >= 0} d_i(n) * p_(i + 1) where d_i(n) = i-th digit of n in base 3, and p_i = i-th prime.

Original entry on oeis.org

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

Views

Author

James Burling, Sep 23 2015

Keywords

Comments

d_i(n) can be found using either of the following formulas:
* d_i(n) = floor(n / 3^i) mod 3;
* d_i(n) = floor(n / 3^i) - 3 * floor(n / 3^(i + 1)).

Examples

			The base 3 representation of n = 5 is 12 so a(5) = 2 * 2 + 1 * 3 = 7.
The base 3 representation of n = 12 is 110 so a(12) = 0 * 2 + 1 * 3 + 1 * 5 = 8.
		

Crossrefs

Similar method, different base for n: A089625 (base 2).
Similar method, uses product for sum index for multiplication: A019565 (base 2), A101278 (base 3), A054842 (base 10).

Programs

  • Mathematica
    Table[Sum[IntegerDigits[n, 3][[-i]] Prime@ i, {i, IntegerLength[n, 3]}], {n, 0, 81}] (* Michael De Vlieger, Sep 24 2015 *)
  • PARI
    a(n) = my(d = Vecrev(digits(n, 3))); sum(k=1, #d, d[k]*prime(k)); \\ Michel Marcus, Sep 24 2015

Formula

a(n) = Sum_{i >= 0} p_(i + 1) * (floor(n / 3^i) - 3 * floor(n / 3^(i + 1))).

A263042 a(n) = Sum_{i >= 1} d_i(n) * prime(i) where d_i(n) is the i-th digit of n in base 10, and prime(i) is the i-th prime.

Original entry on oeis.org

0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36
Offset: 0

Views

Author

James Burling, Oct 08 2015

Keywords

Comments

Digits are counted from the right, so d_1(n) is the ones digit, d_2(n) is the tens digit, etc.
d_i(n) can be found using either of the following formulas:
* d_i(n) = floor(n / 10^(i-1)) mod 10;
* d_i(n) = floor(n / 10^(i-1)) - 10 * floor(n / 10^i).
From Derek Orr, Dec 24 2015: (Start)
For n < 1000, this sequence may be written as a series of 10 X 10 subtables:
Subtable 1:
0, 2, 4, 6, 8, 10, 12, 14, 16, 18
3, 5, 7, 9, 11, 13, 15, 17, 19, 21
6, 8, 10, 12, 14, 16, 18, 20, 22, 24
9, 11, 13, 15, 17, 19, 21, 23, 25, 27
12, 14, 16, 18, 20, 22, 24, 26, 28, 30
15, 17, 19, 21, 23, 25, 27, 29, 31, 33
18, 20, 22, 24, 26, 28, 30, 32, 34, 36
21, 23, 25, 27, 29, 31, 33, 35, 37, 39
24, 26, 28, 30, 32, 34, 36, 38, 40, 42
27, 29, 31, 33, 35, 37, 39, 41, 43, 45
Subtable 2:
5, 7, 9, 11, 13, 15, 17, 19, 21, 23
8, 10, 12, 14, 16, 18, 20, 22, 24, 26
11, 13, 15, 17, 19, 21, 23, 25, 27, 29
14, 16, 18, 20, 22, 24, 26, 28, 30, 32
17, 19, 21, 23, 25, 27, 29, 31, 33, 35
20, 22, 24, 26, 28, 30, 32, 34, 36, 38
23, 25, 27, 29, 31, 33, 35, 37, 39, 41
26, 28, 30, 32, 34, 36, 38, 40, 42, 44
29, 31, 33, 35, 37, 39, 41, 43, 45, 47
32, 34, 36, 38, 40, 42, 44, 46, 48, 50
Subtable 3:
10, 12, 14, 16, 18, 20, 22, 24, 26, 28
13, 15, 17, 19, 21, 23, 25, 27, 29, 31
16, 18, 20, 22, 24, 26, 28, 30, 32, 34
19, 21, 23, 25, 27, 29, 31, 33, 35, 37
22, 24, 26, 28, 30, 32, 34, 36, 38, 40
25, 27, 29, 31, 33, 35, 37, 39, 41, 43
28, 30, 32, 34, 36, 38, 40, 42, 44, 46
31, 33, 35, 37, 39, 41, 43, 45, 47, 49
34, 36, 38, 40, 42, 44, 46, 48, 50, 52
37, 39, 41, 43, 45, 47, 49, 51, 53, 55
...
Each subtable is 10 X 10. Let T_n(j,k) = the element in the j-th row of the k-th column of subtable n. T_n(1,1) = 5*(n-1). T_n(j,1) = 5*(n-1)+3*(j-1). T_n(1,k) = 5*(n-1)+2*(k-1). Altogether, T_n(j,k) = 5*(n-1)+3*(j-1)+2*(k-1) = 5*n+3*j+2*k-10.
(End)

Examples

			For n = 12, the digits are 2 and 1 and the corresponding primes are 2 and 3, so a(12) = (first digit * first prime) + (second digit * second prime) = 2 * 2 + 1 * 3 = 4 + 3 = 7.
		

Crossrefs

Similar method, different base for n: A089625 (base 2), A262478 (base 3).
Similar method, uses product instead of sum: A019565 (base 2), A101278 (base 3), A054842 (base 10).

Programs

  • Mathematica
    Table[Sum_{m=0}^{infinity} (Floor[n/10^(m)] - 10*Floor[n/10^(m+1)])*Prime(m+1), {n,0,500}] (* G. C. Greubel, Oct 08 2015 *)
  • PARI
    a(n) = if (n==0, d = [0], d=Vecrev(digits(n))); sum(i=1,#d, d[i]*prime(i)); \\ Michel Marcus, Oct 10 2015
    
  • PARI
    vector(200,n,n--;sum(i=1,#digits(n),Vecrev(digits(n))[i]*prime(i))) \\ Derek Orr, Dec 24 2015

Formula

a(n) = Sum_{i >= 0} prime(i + 1) * (floor(n / 10^i) - 10 * floor(n / 10^(i + 1))).
Showing 1-10 of 12 results. Next