Skip to content

Instantly share code, notes, and snippets.

@dre4success
Created February 27, 2020 22:28
Show Gist options
  • Save dre4success/22218f5bc2bea8d87aa6fc6fdaa38b9b to your computer and use it in GitHub Desktop.
Save dre4success/22218f5bc2bea8d87aa6fc6fdaa38b9b to your computer and use it in GitHub Desktop.
def multi_imperative(n = 12):
if(n > 12):
return print('maximum number allowed is 12')
for i in range(1,n+1):
s = ''
for j in range(1,n+1):
s += '{0:4} '.format(i*j)
print(s)
multi_imperative()
def multi_iterative(n = 12):
if(n > 12):
return print('maximum number allowed is 12')
def times_table_recursive(number, increment):
maximum = max(increment, 1)
if number <= maximum * n:
print('{:3} '.format(number), end=' ')
times_table_recursive(number + maximum, increment)
elif increment < n:
print()
increment += 1
times_table_recursive(increment, increment)
else:
print()
times_table_recursive(1, 1)
multi_iterative()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment