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