Skip to content

Commit

Permalink
Made more smaller and less memory utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalpak Take authored Jul 9, 2017
1 parent 7748f26 commit 9843926
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions collatz_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ def collatz(num): # defining the function
else:
return 'Enter a valid integer'

while (res == 1): #we need to exit the function after 1 is obtained
print(res)
exit(0)

while (res != 1):
print(res)
num = res
collatz(num) #the function should be executing until 1 is obtained
while True:
if (res == 1): #we need to exit the function after 1 is obtained
print(res)
exit(0)
elif (res != 1):
print(res)
collatz(res) #the function should be executing until 1 is obtained

try:
num = int(input('Enter an integer: ')) #asking for input and then calling the function also change input to raw_input in python 2x versions
Expand Down

0 comments on commit 9843926

Please sign in to comment.