Q. Write recursive code to compute and print sum of squares of n numbers. Value of n is passed as parameter.



Answer =

def sqsum (n):
    if n == 1:
        return 1
    return n * n + sqsum (n-1)

n = int (input ("Enter value of n:"))
print (sqsum (n))


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post