Skip to content

Instantly share code, notes, and snippets.

@ZSendokame
Last active January 9, 2024 05:27
Show Gist options
  • Save ZSendokame/ab1c7f759c7271d70bec9959b9190d64 to your computer and use it in GitHub Desktop.
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.
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