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-3 of 3 results.

A071980 If n = abcd (say) in decimal, then a(n) = a + ab + abc + abcd + bcd + cd + d.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 77, 79
Offset: 0

Views

Author

Amarnath Murthy, Jun 18 2002

Keywords

Examples

			a(1347) = 1 + 13 + 134 + 1347 + 347 + 47 + 7 = 1896.
		

Crossrefs

Cf. A225580. - Zak Seidov, May 16 2013

Programs

  • Maple
    read("transforms"):
    A071980 := proc(n)
        local a,dgs,d ;
        a := n ;
        dgs := convert(n,base,10) ;
        for d from 1 to nops(dgs) do
            [op(d+1..nops(dgs),dgs)] ;
            a := a+digcatL(%) ;
            [op(1..nops(dgs)-d,dgs)] ;
            a := a+digcatL(%) ;
        end do:
        a ;
    end proc: # R. J. Mathar, May 06 2019
  • Mathematica
    f[n_] := Block[{lead = IntegerDigits[n], trail = IntegerDigits[n], flr = Floor[Log[10, n] + 1], s = -n}, While[flr > 0, s = s + FromDigits[lead] + FromDigits[trail]; lead = Drop[lead, -1]; trail = Drop[trail, 1]; flr--]; s]; Table[f[n], {n, 0, 80}]
    Table[n+Sum[Quotient[n,10^k]+Mod[n,10^k],{k,1,Log[10,n]}],{n,0,100}](* Zak Seidov, May 16 2013 *)
  • PARI
    a(n)=local(l); if(n<1,0,l=1+log(n)\log(10); sum(i=1,l-1,n\10^i+n%(10^i),n))

Extensions

Edited by Robert G. Wilson v, Jun 23 2002

A330072 a(n) is the sum of all integers whose binary representation is contained in the binary representation of n (with multiplicity).

Original entry on oeis.org

0, 1, 3, 5, 7, 10, 13, 16, 15, 19, 24, 28, 29, 33, 38, 42, 31, 36, 43, 48, 52, 57, 64, 69, 61, 66, 73, 78, 82, 87, 94, 99, 63, 69, 78, 84, 91, 97, 106, 112, 108, 114, 123, 129, 136, 142, 151, 157, 125, 131, 140, 146, 153, 159, 168, 174, 170, 176, 185, 191, 198
Offset: 0

Views

Author

Tonio Kettner, Nov 30 2019

Keywords

Examples

			For n = 5: 5 in binary is 101, so a(n) = 101 + 10 + 01 + 1 + 0 + 1 in binary, which is 5 + 2 + 1 + 1 + 0 + 1 = 10.
		

Crossrefs

Cf. A007088, A005187, A049802, A078823, A225580 (base-10 version).

Programs

  • Mathematica
    a[n_] := Block[{d = IntegerDigits[n, 2]}, Sum[FromDigits[Take[d, {i, j}], 2], {j, Length[d]}, {i, j}]]; Array[a, 61, 0] (* Giovanni Resta, Dec 02 2019 *)
  • Python
    def bitlist(n):
        output = []
        while n != 0:
            output.append(n % 2)
            n //= 2
        return output
    #converts a number into a list of the digits in binary reversed
    def bitsum(bitlist):
        output = 0
        for bit in bitlist:
            if bit == 1:
                output += 1
        return output
    #gives the cross sum of a bitlist
    def a(bitlist):
        output = 0
        l = len(bitlist)
        for x in range(l):
            output += bitlist[x] * (l - x) * (2**(x + 1) - 1)
        return output
    #to get the first 60 numbers of the sequence, write:
    for x in range(0, 60):
        print(a(bitlist(x)))
    
  • Python
    def a(n):
        b = n.bit_length()
        return sum((n//2**i) % (2**j) for i in range(b+1) for j in range(b-i+1))
    # David Radcliffe, May 14 2025

Formula

a(2^k) = 2^(k+1)-1.
a(2^k-1) = (8*2^k-8-5*k-k^2)/2. - Giovanni Resta, Dec 02 2019
From David Radcliffe, May 14 2025: (Start)
a(n) = Sum_{i=0..b} Sum_{j=0..b-i} ([n/2^i] mod 2^j) where b is the bit length of n.
a(n) - 3a([n/2]) + 2a([n/4]) = A070939(n) if n is odd, 0 otherwise. (End)

A365276 Sum of all prime substrings of n in base 10, including n itself and duplicate or overlapping substrings but not substrings with a leading 0.

Original entry on oeis.org

0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 2, 16, 0, 5, 0, 24, 0, 19, 2, 2, 4, 28, 2, 7, 2, 9, 2, 31, 3, 34, 5, 6, 3, 8, 3, 47, 3, 3, 0, 41, 2, 46, 0, 5, 0, 54, 0, 0, 5, 5, 7, 61, 5, 10, 5, 12, 5, 64, 0, 61, 2, 3, 0, 5, 0, 74, 0, 0, 7, 78, 9, 83, 7, 12, 7, 14, 7, 86, 0
Offset: 0

Views

Author

Wade Reece Eberly, Aug 30 2023

Keywords

Examples

			a(25) = 2 + 5 = 7.
a(37) = 3 + 7 + 37 = 47.
a(3002) = 3 + 2 = 5.
a(1235) = 2 + 3 + 5 + 23 = 33.
Example including duplicate and overlapping prime substrings:
a(227111) = 2 + 2 + 7 + 11 + 11 + 71 + 227 + 271 + 2711 + 227111 = 230424.
Note that in the above example, the substring 2 is incorporated into the sum twice because it appears twice in n.  The same is true of the substring 11, whose two appearances overlap each other in the final three digits of n.
Example wherein substrings with a leading 0 are to be ignored:
a(1002) = 2 because the substrings 002 and 02 are to be ignored due to the presence of a leading 0.
		

Crossrefs

Programs

  • PARI
    a(n)={my(v=digits(n)); sum(j=1, #v, sum(i=1, j, if(v[i], my(t=fromdigits(v[i..j])); t*isprime(t))))} \\ Andrew Howroyd, Aug 30 2023
    
  • Python
    from sympy import isprime
    def a(n):
        s = str(n)
        ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
        return sum(p for w in ss if w[0]!="0" and isprime(p:=int(w)))
    print([a(n) for n in range(81)]) # Michael S. Branicky, Aug 30 2023

Extensions

More terms from Andrew Howroyd, Aug 30 2023
Showing 1-3 of 3 results.