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

A383327 a(n) is the number of occurrences of n in A049802.

Original entry on oeis.org

1, 2, 1, 4, 1, 2, 3, 5, 1, 3, 2, 5, 2, 4, 1, 7, 2, 4, 2, 5, 3, 5, 1, 6, 3, 4, 2, 6, 3, 3, 2, 10, 3, 4, 1, 5, 4, 5, 3, 8, 3, 5, 2, 6, 2, 5, 2, 10, 3, 4, 2, 7, 2, 5, 3, 8, 4, 5, 2, 5, 2, 7, 1, 14, 1, 5, 5, 5, 1, 4, 4, 11, 3, 6, 3, 7, 2, 6, 2, 10, 2, 6, 3, 8, 3, 6, 4, 11
Offset: 1

Views

Author

Miles Englezou, Apr 23 2025

Keywords

Comments

The offset is 1 since A049802(k) = 0 for infinitely many values (when k = 2^r, r >= 0).
Every m > 0 in A049802 has a finite multiplicity, since, except for n = 2, the range of numbers for which A049802(k) = s is bounded above by 2^s+1 (see Englezou link).
The tuple of summands (x_1, ..., x_t) for m in A049802 can also be seen as a finite subset of an infinite tuple which is the representation of m as a profinite integer isomorphic to the normalized 2-adic series of m. This is because m is an element of the inverse limit of the finite rings Z/(2^i)Z, which is a profinite group isomorphic to the ring of 2-adic integers. In the infinite tuple (x_1, x_2, ...), x_i = m for every i such that m < 2^i. For example, for m = 29, we have the tuple (1, 1, 5, 13, 29, 29, 29, ...). See the Wikipedia link for more information.
From a combinatorial perspective, the tuple of summands (x_1, ..., x_t) mentioned above can be seen as a set of t counters, where the j-th counter cycles through 0 to 2^j-1. The natural question 'which m in A049802 appear k times?' becomes a question about how this cycling condition restricts the number of tuples which sum to m. For example, for n <= 100, when n = 1, 3, 5, 9, 15, 23, 35, 63, 65, and 67 there is only one m such that the tuple of summands sums to n (a trivial tuple consisting of n 1s, trivial because there is such a tuple for every n >= 1, i.e. for every m = 2^n+1).

Examples

			 n |a(n)| k such that A049802(k) = n
---+----+------------------------------------
 1 | 1  | {3}
 2 | 2  | {5, 6}
 3 | 1  | {9}
 4 | 4  | {7, 10, 12, 17}
 5 | 1  | {33}
 6 | 2  | {18, 65}
 7 | 3  | {11, 13, 129}
 8 | 5  | {14, 20, 24, 34, 257}
 9 | 1  | {513}
10 | 3  | {19, 66, 1025}
11 | 2  | {15, 2049}
12 | 5  | {21, 25, 36, 130, 4097}
13 | 2  | {35, 8193}
14 | 4  | {22, 26, 258, 16385}
15 | 1  | {32769}
16 | 7  | {28, 40, 48, 67, 68, 514, 65537}
17 | 2  | {37, 131073}
18 | 4  | {23, 27, 1026, 262145}
19 | 2  | {131, 524289}
20 | 5  | {29, 38, 132, 2050, 1048577}
21 | 3  | {41, 49, 2097153}
22 | 5  | {30, 69, 259, 4098, 4194305}
23 | 1  | {8388609}
24 | 6  | {42, 50, 72, 260, 8194, 16777217}
25 | 3  | {39, 515, 33554433}
26 | 4  | {31, 70, 16386, 67108865}
---------------------------------------------
Let (x_1, ..., x_k) be the tuple of summands as described in the comments.
Then for:
n = 4, a(4) = 4
  7: (1, 3)
  10: (0, 2, 2)
  12: (0, 0, 4)
  17: (1, 1, 1, 1)
n = 12, a(12) = 5
  21: (1, 1, 5, 5)
  25: (1, 1, 1, 9)
  36: (0, 0, 4, 4, 4)
  130: (0, 2, 2, 2, 2, 2, 2)
  4097: (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
n = 20, a(20) = 5
  29: (1, 1, 5, 13)
  38: (0, 2, 6, 6, 6)
  132: (0, 0, 4, 4, 4, 4, 4)
  2050: (0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
  1048577: (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
		

Crossrefs

Programs

  • PARI
    a(n) = my(S=[],s); if(n==2, return(2)); for(m=1, 2^n+1, s=sum(k=1, logint(m, 2), m%2^k); if(n==s, S=concat(S, m))); return(#S)
    
  • PARI
    a(n) = local(tuple_sum, section, expansion, T=[], breakout, S, K); (tuple_sum(m) = sum(k=1, logint(m, 2), m % 2^k)); (section(r) = my(S=[]); for(n=1, 2^(r+1), if(logint(n,2)==r, S=concat(S,n))); return(S[#S/2+1..#S])); (expansion(a,l) = my(k=a, K=[]); K=concat(K, a); for(n=1, l-1, K=concat(K, k+2^(logint(a, 2)-1+n)); k=k+2^(logint(a, 2)-1+n)); return(K)); for(k=1, n, for(i=1, #section(k), breakout=0; if(tuple_sum(section(k)[1]) > n, breakout=1); K=expansion(section(k)[i], n); for(j=1, #K, if(tuple_sum(K[j]) > n, break, if(tuple_sum(K[j])==n, T=concat(T,K[j]); break)))); if(breakout==1,break)); return(#T)

Formula

a(n) <= A000041(n).

A049803 a(n) = n mod 3 + n mod 9 + ... + n mod 3^k, where 3^k <= n < 3^(k+1).

Original entry on oeis.org

0, 0, 0, 1, 2, 0, 1, 2, 0, 2, 4, 3, 5, 7, 6, 8, 10, 0, 2, 4, 3, 5, 7, 6, 8, 10, 0, 3, 6, 6, 9, 12, 12, 15, 18, 9, 12, 15, 15, 18, 21, 21, 24, 27, 18, 21, 24, 24, 27, 30, 30, 33, 36, 0, 3, 6, 6, 9, 12, 12, 15, 18, 9, 12, 15, 15, 18, 21, 21, 24, 27, 18
Offset: 1

Views

Author

Keywords

Comments

From Petros Hadjicostas, Dec 11 2019: (Start)
Conjecture: For b >= 2, consider the function s(n,b) = Sum_{1 <= b^j <= n} (n mod b^j) from p. 8 in Dearden et al. (2011). Then s(b*n + r, b) = b*s(n,b) + r*N(n,b) for 0 <= r <= b-1, where N(n,b) = floor(log_b(n)) + 1 is the number of digits in the base-b representation of n. As initial conditions, we have s(n,b) = 0 for 1 <= n <= b. (This is a generalization of a result by Robert Israel in A049802.)
Here b = 3 and a(n) = s(n,3).
We have N(n,2) = A070939(n), N(n,3) = A081604(n), N(n,4) = A110591(n), and N(n,5) = A110592(n).
If A_b(x) = Sum_{n >= 1} s(n,b)*x^n is the g.f. of the sequence (s(n,b): n >= 1) and the above conjecture is correct, then it can be proved that A_b(x) = b * A_b(x^b) * (1-x^b)/(1-x) + x * ((b-1)*x^b - b*x^(b-1) + 1)/((1-x)^2 * (1-x^b)) * Sum_{k >= 1} x^(b^k). (End)

Crossrefs

Programs

  • Maple
    a:= n-> add(irem(n, 3^j), j=1..ilog[3](n)):
    seq(a(n), n=1..105);  # Alois P. Heinz, Dec 13 2019
  • Mathematica
    Table[n * Floor@Log[3, n] - Sum[Floor[n*3^-k]*3^k, {k, Log[3, n]}], {n, 100}] (* after Federico Provvedi in A049802*) (* Metin Sariyar, Dec 12 2019 *)
  • PARI
    a(n) = sum(k=1, logint(n, 3), n % 3^k); \\ Michel Marcus, Dec 12 2019

Formula

From Petros Hadjicostas, Dec 11 2019: (Start)
Conjecture: a(3*n+r) = 3*a(n) + r*A081604(n) = 3*a(n) + r*(floor(log_3(n)) + 1) for n >= 1 and r = 0, 1, 2.
If the conjecture above is true, the g.f. A(x) satisfies A(x) = 3*(1+x+x^2)*A(x^3) + x*(2*x+1)/(1-x^3) * Sum_{k >= 1} x^(3^k). (End)

A049804 a(n) = n mod 4 + n mod 16 + ... + n mod 4^k, where 4^k <= n < 4^(k+1).

Original entry on oeis.org

0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 2, 4, 6, 4, 6, 8, 10, 8, 10, 12, 14, 12, 14, 16, 18, 0, 2, 4, 6, 4, 6, 8, 10, 8, 10, 12, 14, 12, 14, 16, 18, 0, 2, 4, 6, 4, 6, 8, 10, 8, 10, 12, 14, 12, 14, 16, 18, 0, 3, 6, 9, 8, 11, 14, 17, 16, 19, 22
Offset: 1

Views

Author

Keywords

Comments

From Petros Hadjicostas, Dec 11 2019: (Start)
Conjecture: For b >= 2, consider the function s(n,b) = Sum_{1 <= b^j <= n} (n mod b^j) from p. 8 in Dearden et al. (2011). Then s(b*n + r, b) = b*s(n,b) + r*N(n,b) for 0 <= r <= b-1, where N(n,b) = floor(log_b(n)) + 1 is the number of digits in the base-b representation of n. As initial conditions, we have s(n,b) = 0 for 1 <= n <= b. (This is a generalization of a result by Robert Israel in A049802.)
Here b = 4 and a(n) = s(n,4).
We have N(n,2) = A070939(n), N(n,3) = A081604(n), N(n,4) = A110591(n), and N(n,5) = A110592(n).
If A_b(x) = Sum_{n >= 1} s(n,b)*x^n is the g.f. of the sequence (s(n,b): n >= 1) and the above conjecture is correct, then it can be proved that A_b(x) = b * A_b(x^b) * (1-x^b)/(1-x) + x * ((b-1)*x^b - b*x^(b-1) + 1)/((1-x)^2 * (1-x^b)) * Sum_{k >= 1} x^(b^k). (End)

Crossrefs

Programs

  • Maple
    a:= n-> add(irem(n, 4^j), j=1..ilog[4](n)):
    seq(a(n), n=1..105);  # Petros Hadjicostas, Dec 13 2019 (after Alois P. Heinz's program for A330358)
  • Mathematica
    Table[n * Floor@Log[4, n] - Sum[Floor[n*4^-k]*4^k, {k, Log[4, n]}], {n, 100}] (* Metin Sariyar, Dec 12 2019 *)
    a[n_] := Sum[Mod[n, 4^j], {j, 1, Length[IntegerDigits[n, 4]] - 1}];
    Array[a, 105] (* Jean-François Alcover, Dec 31 2021 *)
  • PARI
    a(n) = sum(k=1, logint(n, 4), n % 4^k); \\ Michel Marcus, Dec 12 2019

Formula

From Petros Hadjicostas, Dec 11 2019: (Start)
Conjecture: a(4*n+r) = 4*a(n) + r*A110591(n) = 4*a(n) + r*(floor(log_4(n)) + 1) for n >= 1 and r = 0, 1, 2, 3.
If the conjecture above is true, the g.f. A(x) satisfies A(x) = 4*(1 + x + x^2 + x^3)*A(x^4) + x*(1 + 2*x + 3*x^2)/(1 - x^4) * Sum_{k >= 1} x^(4^k). (End)

A330358 a(n) = n mod 5 + n mod 25 + ... + n mod 5^k, where 5^k <= n < 5^(k+1).

Original entry on oeis.org

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

Views

Author

Petros Hadjicostas, Dec 12 2019

Keywords

Comments

Conjecture: For b >= 2, consider the function s(n,b) = Sum_{1 <= b^j <= n} (n mod b^j) from p. 8 in Dearden et al. (2011). Then s(b*n + r, b) = b*s(n,b) + r*N(n,b) for 0 <= r <= b-1, where N(n,b) = floor(log_b(n)) + 1 is the number of digits in the base-b representation of n. As initial conditions, we have s(n,b) = 0 for 1 <= n <= b. (This is a generalization of a result by Robert Israel in A049802.)
Here b = 5 and a(n) = s(n,5).
We have N(n,2) = A070939(n), N(n,3) = A081604(n), N(n,4) = A110591(n), and N(n,5) = A110592(n).
If A_b(x) = Sum_{n >= 1} s(n,b)*x^n is the g.f. of the sequence (s(n,b): n >= 1) and the above conjecture is correct, then it can be proved that A_b(x) = b * A_b(x^b) * (1-x^b)/(1-x) + x * ((b-1)*x^b - b*x^(b-1) + 1)/((1-x)^2 * (1-x^b)) * Sum_{k >= 1} x^(b^k).

Crossrefs

Programs

  • Maple
    a:= n-> add(irem(n, 5^j), j=1..ilog[5](n)):
    seq(a(n), n=1..105);  # Alois P. Heinz, Dec 13 2019
  • Mathematica
    a[n_] := Sum[Mod[n, 5^j], {j, 1, Length[IntegerDigits[n, 5]] - 1}];
    Array[a, 105] (* Jean-François Alcover, Dec 31 2021 *)
  • PARI
    a(n) = sum(k=1, logint(n, 5), n % 5^k);
    for(n=1, 100, print1(a(n), ", ")); \\ (after Michel Marcus's program in A049804)

Formula

Conjecture: a(5*n+r) = 5*a(n) + r*A110592(n) = 5*a(n) + r*(floor(log_5(n)) + 1) for n >= 1 and r = 0, 1, 2, 3, 4.
If the conjecture above is true, the g.f. A(x) satisfies A(x) = 5*(1 + x + x^2 + x^3 + x^4)*A(x^5) + x*(1 + 2*x + 3*x^2 + 4*x^3)/(1 - x^5) * Sum_{k >= 1} x^(5^k).

A383844 a(n) is the number of occurences of n in A024934.

Original entry on oeis.org

3, 3, 0, 1, 2, 0, 1, 1, 3, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1
Offset: 0

Views

Author

Miles Englezou, May 12 2025

Keywords

Comments

Every k in A024934 is the sum of a tuple (x_1, ..., x_t) for prime(t) <= k < prime(t+1), where x_i = k mod prime(i). The tuples can be seen combinatorially as sets of t counters where the i-th counter cycles through 0 to prime(i)-1.
Since A024934(n) > n for n > 21, the set of numbers k for which A024934(k) = n is bounded above by n for those n, though smaller bounds are possible.
It is interesting to compare A024934 to A049802 (and likewise the current sequence with A383327). Every m in A049802 is also the sum of a tuple of congruences except the moduli are ascending powers of 2. Ordered by divisibility, the set of moduli in A049802 therefore form a chain (i.e., they are totally ordered) whilst the set of moduli in A024934 form an antichain (no one modulus divides any other). These opposed orders mean the two sequences behave quite differently.
Comparison of A049802 and A383327 vs. A024934 and {a(n)}:
- 0 appears infinitely many times in A049802, for every m = 2^n. Therefore 0 is not a term of A383327.
- A049802(2^n+1) = n. Therefore every n appears at least once in A049802.
- It is likely that every n appears at least once in A383327, however this is currently conjectural.
- If A049802(k) = m for 2^r-2^(r-2) <= k < 2^r, and if the rightmost summand in the tuple of m is x, then for s >= 0, A049802(k+2^((r-1)+s)) = m + x*(s+1).
A024934 and {a(n)}:
- 0 appears 3 times in A024934, for n = 0, 1, 2. Therefore a(0) = 3.
- It is not true that every n appears at least once in A024934 (e.g., 2 and 5 are not terms), and this is likely to be the case for infinitely many n, meaning it is likely that a(n) = 0 for infinitely many n.
- It appears to be unlikely that a(k) = n for every n: for 0 < n < 3500, a(n) <= 3 (and a(n) = 3 only for n = 0, 1, 8, 37, 781).

Examples

			 n | a(n) | k such that A024934(k) = n
---+------+---------------------------
 0 |  3   | {0, 1, 2}
 1 |  3   | {3, 4, 6}
 2 |  0   | {}
 3 |  1   | {5}
 4 |  2   | {7, 10}
 5 |  0   | {}
 6 |  1   | {8}
 7 |  1   | {9}
 8 |  3   | {11, 12, 15}
 9 |  0   | {}
10 |  1   | {14}
11 |  0   | {}
12 |  1   | {16}
13 |  1   | {13}
14 |  0   | {}
15 |  0   | {}
16 |  0   | {}
17 |  0   | {}
18 |  1   | {17}
19 |  0   | {}
20 |  1   | {18}
--------------------------------------
Illustration of some tuples
 n | A024934(n) |     tuple of n
---+------------+---------------------
 0 |     0      | ()
 1 |     0      | ()
 2 |     0      | (0)
 3 |     1      | (1 0)
 4 |     1      | (0 1)
 5 |     3      | (1 2 0)
 6 |     1      | (0 0 1)
 7 |     4      | (1 1 2 0)
 8 |     6      | (0 2 3 1)
 9 |     7      | (1 0 4 2)
10 |     4      | (0 1 0 3)
11 |     8      | (1 2 1 4 0)
12 |     9      | (0 0 2 5 1)
13 |    13      | (1 1 3 6 2 0)
14 |    10      | (0 2 4 0 3 1)
15 |     8      | (1 0 0 1 4 2)
16 |    12      | (0 1 1 2 5 3)
17 |    18      | (1 2 2 3 6 4 0)
18 |    20      | (0 0 3 4 7 5 1)
19 |    27      | (1 1 4 5 8 6 2 0)
20 |    28      | (0 2 0 6 9 7 3 1)
		

Crossrefs

Programs

  • PARI
    a(n) = my(f, S=[], b); (f(m) = my(r=0); forprime(p=2, m, r+=m%p); return(r)); if(n<=21, b=26, b=n); for(k=0, b, if(f(k)==n, S=concat(S, k))); return(#S)

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)

A384544 Numbers k such that A383327(k) = 1.

Original entry on oeis.org

1, 3, 5, 9, 15, 23, 35, 63, 65, 69, 113, 125, 141, 149, 173, 209, 231, 275, 279, 299, 321, 353, 365, 383, 419, 465, 509, 519, 555, 575, 603, 653, 695, 749, 765, 875, 945, 951, 959, 983
Offset: 1

Views

Author

Miles Englezou, Jun 02 2025

Keywords

Comments

Numbers k such that there is only one m such that Sum_{i=1..t} m mod 2^i for 2^t <= m < 2^(t+1) is equal to k (see A049802). Every m = 2^k+1 (see A383327).
All terms are odd since for every even r there are at least two numbers u, v where the congruences sum to r (for u = 2^r+1 and v = 2^(r/2+1)+2).

Examples

			3 is a term since 2^3+1 = 9 is the only number such that the congruences sum to 3.
15 is a term since 2^15+1 = 32769 is the only number such that the congruences sum to 15.
63 is a term since 2^63+1 = 9223372036854775809 is the only number such that the congruences sum to 63.
		

Crossrefs

Programs

  • PARI
    isok(n) = (count(n) = local(tuple_sum, section, expansion, T=[], breakout, S, K); (tuple_sum(m) = sum(k=1, logint(m, 2), m % 2^k)); (section(r) = my(S=[]); for(n=1, 2^(r+1), if(logint(n, 2)==r, S=concat(S, n))); return(S[#S/2+1..#S])); (expansion(a, l) = my(k=a, K=[]); K=concat(K, a); for(n=1, l-1, K=concat(K, k+2^(logint(a, 2)-1+n)); k=k+2^(logint(a, 2)-1+n)); return(K)); for(k=1, n, for(i=1, #section(k), breakout=0; if(tuple_sum(section(k)[1]) > n, breakout=1); K=expansion(section(k)[i], n); for(j=1, #K, if(tuple_sum(K[j]) > n, break, if(tuple_sum(K[j])==n, T=concat(T, K[j]); break)))); if(breakout==1, break)); return(#T)); if(count(n)==1, return(1), return(0))
Showing 1-7 of 7 results.