Last active
January 9, 2024 05:27
-
-
Save ZSendokame/ab1c7f759c7271d70bec9959b9190d64 to your computer and use it in GitHub Desktop.
Return composition of a number n, checking divisibility by all numbers up to a ceiling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compound(n, ceiling: int = 10, powers: list = []): | |
for i in range(2, ceiling): | |
if n % i == 0: | |
powers.append(i) | |
return compound(n // i, ceiling, powers) | |
powers.append(n) | |
return powers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment