Created
April 25, 2020 06:26
-
-
Save computer-tutor/227b59212a5b2fb3f285161743b44329 to your computer and use it in GitHub Desktop.
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 generate_hail_seq(n): | |
lnum=[n] | |
while n!=1: | |
if(n%2)==0: | |
n=n//2 | |
lnum.append(n) | |
else: | |
n=(n*3)+1 | |
lnum.append(n) | |
return lnum | |
print(generate_hail_seq(10)) | |
print(generate_hail_seq(7)) | |
print(generate_hail_seq(8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment