Q. Write a program to display first four multiples of a number using recursion.
Answer =
def multi(n,x): if x == 4 : print(n*x) else : print(n*x,end =",") multi(n,x+1) num = int(input("Enter a number :-")) multi(num,1)
Output :-
Enter a number :-5
5,10,15,20
>>>
5,10,15,20
>>>
Enter a number :-14
14,28,42,56
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )