Advertisement
maynul67

sum of square of all numbers upto n

Jul 10th, 2021
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. def square_series(n):
  2.     sum = 0
  3.     while n >= 0:
  4.         sum = sum + n**2
  5.         n = n - 1
  6.     return sum
  7. sum = square_series(int(input("Enter number n : ")))
  8. print("Sum of 0²+1²+......+n² is:",sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement