Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
207 B
6
Indexable
Never
def square_of_natural_numbers(n):
    return sum(i ** 2 for i in range(1, n + 1))

# Example usage:
n = 5
result = square_of_natural_numbers(n)
print("Square of the first", n, "natural numbers is:", result)
Leave a Comment