Skip to content

Instantly share code, notes, and snippets.

@theabhayprajapati
Created September 2, 2022 06:55
Show Gist options
  • Save theabhayprajapati/e4fb0b5156c746f4b397033e47bbb7e1 to your computer and use it in GitHub Desktop.
Save theabhayprajapati/e4fb0b5156c746f4b397033e47bbb7e1 to your computer and use it in GitHub Desktop.
Prove by mathematical induction n(n+1)(n+2) is divisible by 24
""" prove by mathematical induction n(n+1)(n+2) is divisible by 24 """
def main(n):
""" main function """
if n * (n + 1) * (n + 2) % 6 == 0:
print(n, "is divisible by 6")
return main(n + 1)
else:
print(n, "is not divisible by 6")
n += 1
return main(n)
main(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment