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).

This page as a plain text file.
%I A330733 #48 Jul 18 2021 19:26:53
%S A330733 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,
%T A330733 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,
%U A330733 2,4,0,6,0,4,2,3,0,8,0,0,0,0,0,0,0,0,0,0,0,0,1
%N A330733 Triangle read by rows in which row n is the "complete rhythm" of n (see Comments for precise definition).
%C A330733 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].
%C A330733 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.)
%C A330733 E.g., n=4 has a unique proper factor f=2 (whose complete rhythm is simply its natural rhythm, since 2 is prime).
%C A330733 Thus, for 4, we must add the following two components:
%C A330733   [0, 0, 0, 1]  (the natural rhythm of 4)
%C A330733 + [0, 1, 0, 1]  (the rhythm of 2, repeated to give 4 terms)
%C A330733 ==============
%C A330733   [0, 1, 0, 2]  (the complete rhythm of 4).
%C A330733 Right diagonal is A002033 (conjectured).
%C A330733 Any prime column stripped of zeros also yields A002033 (conjectured).
%C A330733 From _Michael De Vlieger_, Dec 29 2019: (Start)
%C A330733 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.
%C A330733 Conversely, nonzero positions in each row n > 1 are in the cototient of n (A121998), their number given by row n of A051953. (End)
%e A330733 Here are the rhythms of the first thirteen positive integers:
%e A330733    1 | 1
%e A330733    2 | 0,  1
%e A330733    3 | 0,  0,  1
%e A330733    4 | 0,  1,  0,  2
%e A330733    5 | 0,  0,  0,  0,  1
%e A330733    6 | 0,  1,  1,  1,  0,  3
%e A330733    7 | 0,  0,  0,  0,  0,  0,  1
%e A330733    8 | 0,  2,  0,  3,  0,  2,  0,  4
%e A330733    9 | 0,  0,  1,  0,  0,  1,  0,  0,  2
%e A330733   10 | 0,  1,  0,  1,  1,  1,  0,  1,  0,  3
%e A330733   11 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
%e A330733   12 | 0,  3,  2,  4,  0,  6,  0,  4,  2,  3,  0,  8
%e A330733   13 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
%e A330733 .
%e A330733 The complete rhythm of 12 is composed as follows:
%e A330733 12 has a "natural rhythm" of
%e A330733   12 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
%e A330733 12 has proper divisors 2, 3, 4 and 6, whose complete rhythms are
%e A330733    2 | 0,  1
%e A330733    3 | 0,  0,  1
%e A330733    4 | 0,  1,  0,  2
%e A330733    6 | 0,  1,  1,  1,  0,  3
%e A330733 When the padded (i.e., repeated) rhythms of the proper factors are added to the natural rhythm of 12, we have
%e A330733    2 | 0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1
%e A330733    3 | 0,  0,  1,  0,  0,  1,  0,  0,  1,  0,  0,  1
%e A330733    4 | 0,  1,  0,  2,  0,  1,  0,  2,  0,  1,  0,  2
%e A330733    6 | 0,  1,  1,  1,  0,  3,  0,  1,  1,  1,  0,  3
%e A330733   12 | 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1
%e A330733   ===+==============================================
%e A330733   12 | 0,  3,  2,  4,  0,  6,  0,  4,  2,  3,  0,  8
%t A330733 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 *)
%o A330733 (Python)
%o A330733 def memoize(f):
%o A330733     memo = {}
%o A330733     def helper(x):
%o A330733         if x not in memo:
%o A330733             memo[x] = f(x)
%o A330733         return memo[x]
%o A330733     return helper
%o A330733 @memoize
%o A330733 def unique_factors_of(n):
%o A330733     factors = []
%o A330733     for candidate in range(2, n//2 + 1):
%o A330733         if n % candidate == 0:
%o A330733             factors.append(candidate)
%o A330733     return factors
%o A330733 @memoize
%o A330733 def is_prime(n):
%o A330733     if n <= 1:
%o A330733         return False
%o A330733     if n <= 3:
%o A330733         return True
%o A330733     if n % 2 == 0 or n % 3 == 0:
%o A330733         return False
%o A330733     i = 5
%o A330733     while i * i <= n:
%o A330733         if n % i == 0 or n % (i + 2) == 0:
%o A330733             return False
%o A330733         i = i + 6
%o A330733     return True
%o A330733 @memoize
%o A330733 def rhythm(n):
%o A330733     if n == 0:
%o A330733         return [0]
%o A330733     natural_rhythm_of_n = [0]*(n-1)
%o A330733     natural_rhythm_of_n += [1]
%o A330733     if is_prime(n):
%o A330733         return natural_rhythm_of_n
%o A330733     else:
%o A330733         component_rhythms = [natural_rhythm_of_n]
%o A330733         for divisor in unique_factors_of(n):
%o A330733             component_rhythm = n//divisor * rhythm(divisor)
%o A330733             component_rhythms.append(component_rhythm)
%o A330733         return [sum(i) for i in zip(*component_rhythms)]
%o A330733 for i in range(0, 201):
%o A330733     formatted_string = f'{str(i).rjust(3)}|'
%o A330733     for note in rhythm(i):
%o A330733         formatted_string += f'{str(note).rjust(4)}'
%o A330733     print(formatted_string)
%Y A330733 Cf. A002033 (number of perfect partitions of n), A000040 (prime numbers), A000010, A038566, A051953, A121998.
%K A330733 nonn,tabl
%O A330733 1,10
%A A330733 _Andrew Hood_, Dec 28 2019
%E A330733 Name clarified by _Omar E. Pol_ and _Jon E. Schoenfield_, Dec 31 2019