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.

A330733 Triangle read by rows in which row n is the "complete rhythm" of n (see Comments for precise definition).

Original entry on oeis.org

1, 0, 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 3, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 2, 0, 4, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 1, 0, 1, 1, 1, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 4, 0, 6, 0, 4, 2, 3, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
Offset: 1

Views

Author

Andrew Hood, Dec 28 2019

Keywords

Comments

Define the "natural rhythm" of any positive integer n to be the sequence consisting of n-1 zeros followed by 1; e.g., the natural rhythm of 5 is [0, 0, 0, 0, 1].
Define the "complete rhythm" of any positive integer n to be the term-by-term sum of the natural rhythm of n and the complete rhythm of f for every proper divisor f of n, extended through n/f cycles so as to give n terms. (Thus the complete rhythm of any noncomposite number is simply its natural rhythm.)
E.g., n=4 has a unique proper factor f=2 (whose complete rhythm is simply its natural rhythm, since 2 is prime).
Thus, for 4, we must add the following two components:
[0, 0, 0, 1] (the natural rhythm of 4)
+ [0, 1, 0, 1] (the rhythm of 2, repeated to give 4 terms)
==============
[0, 1, 0, 2] (the complete rhythm of 4).
Right diagonal is A002033 (conjectured).
Any prime column stripped of zeros also yields A002033 (conjectured).
From Michael De Vlieger, Dec 29 2019: (Start)
Positions of 0 in each row n > 1 are in the reduced residue system of n (A038566). Therefore the number of zeros in each row n > 1 is given by the Euler totient function (A000010). This arises because a nonzero addend is introduced for multiples of divisors of n; the numbers k < n such that gcd(k,n) = 1 remain 0.
Conversely, nonzero positions in each row n > 1 are in the cototient of n (A121998), their number given by row n of A051953. (End)

Examples

			Here are the rhythms of the first thirteen positive integers:
   1 | 1
   2 | 0,  1
   3 | 0,  0,  1
   4 | 0,  1,  0,  2
   5 | 0,  0,  0,  0,  1
   6 | 0,  1,  1,  1,  0,  3
   7 | 0,  0,  0,  0,  0,  0,  1
   8 | 0,  2,  0,  3,  0,  2,  0,  4
   9 | 0,  0,  1,  0,  0,  1,  0,  0,  2
  10 | 0,  1,  0,  1,  1,  1,  0,  1,  0,  3
  11 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
  12 | 0,  3,  2,  4,  0,  6,  0,  4,  2,  3,  0,  8
  13 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
.
The complete rhythm of 12 is composed as follows:
12 has a "natural rhythm" of
  12 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
12 has proper divisors 2, 3, 4 and 6, whose complete rhythms are
   2 | 0,  1
   3 | 0,  0,  1
   4 | 0,  1,  0,  2
   6 | 0,  1,  1,  1,  0,  3
When the padded (i.e., repeated) rhythms of the proper factors are added to the natural rhythm of 12, we have
   2 | 0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1
   3 | 0,  0,  1,  0,  0,  1,  0,  0,  1,  0,  0,  1
   4 | 0,  1,  0,  2,  0,  1,  0,  2,  0,  1,  0,  2
   6 | 0,  1,  1,  1,  0,  3,  0,  1,  1,  1,  0,  3
  12 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
  ===+==============================================
  12 | 0,  3,  2,  4,  0,  6,  0,  4,  2,  3,  0,  8
		

Crossrefs

Cf. A002033 (number of perfect partitions of n), A000040 (prime numbers), A000010, A038566, A051953, A121998.

Programs

  • Mathematica
    Nest[Function[{a, n, d}, Append[#1, Total@ Map[PadRight[a[[#]], n, a[[#]] ] &, d] + Append[ConstantArray[0, n - 1], 1]]] @@ {#1, #2, Most@ Rest@ Divisors[#2]} & @@ {#, Length@ # + 1} &, {{1}}, 12] // Flatten (* Michael De Vlieger, Dec 29 2019 *)
  • Python
    def memoize(f):
        memo = {}
        def helper(x):
            if x not in memo:
                memo[x] = f(x)
            return memo[x]
        return helper
    @memoize
    def unique_factors_of(n):
        factors = []
        for candidate in range(2, n//2 + 1):
            if n % candidate == 0:
                factors.append(candidate)
        return factors
    @memoize
    def is_prime(n):
        if n <= 1:
            return False
        if n <= 3:
            return True
        if n % 2 == 0 or n % 3 == 0:
            return False
        i = 5
        while i * i <= n:
            if n % i == 0 or n % (i + 2) == 0:
                return False
            i = i + 6
        return True
    @memoize
    def rhythm(n):
        if n == 0:
            return [0]
        natural_rhythm_of_n = [0]*(n-1)
        natural_rhythm_of_n += [1]
        if is_prime(n):
            return natural_rhythm_of_n
        else:
            component_rhythms = [natural_rhythm_of_n]
            for divisor in unique_factors_of(n):
                component_rhythm = n//divisor * rhythm(divisor)
                component_rhythms.append(component_rhythm)
            return [sum(i) for i in zip(*component_rhythms)]
    for i in range(0, 201):
        formatted_string = f'{str(i).rjust(3)}|'
        for note in rhythm(i):
            formatted_string += f'{str(note).rjust(4)}'
        print(formatted_string)

Extensions

Name clarified by Omar E. Pol and Jon E. Schoenfield, Dec 31 2019