forked from SushmitaY/mca101_2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinc.py
More file actions
29 lines (25 loc) · 762 Bytes
/
inc.py
File metadata and controls
29 lines (25 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def increment(num):
'''
objective: to increment the value of a integer by 1
input parameters: num -> number to be incremented by one
return value: num + 1, successor of the given number
'''
'''
approach: using '+' operator to add 1 to the input number
'''
return num + 1
def mySum(num1, num2):
'''
objective: to find the sum of two numbers
parameters: num1 -> first non negative integer
num2 -> second non negative integer
return value: sum of num1 and num2
'''
'''
approach: using function increment() and using mySum() recursively
'''
assert num1 >= 0 and num2 >= 0
if num2 == 0:
return num1
else:
return mySum(increment(num1), num2 - 1)