Computer Science, asked by nevonj2am, 3 months ago

write a python program to print the sum of the squares of even numbers upto a limit

Answers

Answered by Anonymous
4

Explanation:

How do you print the sum of even numbers in Python?

Logic. First, we declare one variable ” sum ” with value 0, and then we are going to use this variable to store sum of all even numbers between 1 to N. Now after taking input (N) from user, we have to check if the current variable “i” is even or not inside the loop

Answered by kumaraditya029940
1

Answer:

Output is 30

Explanation:

Input : N = 4

Output : 30

12 + 22 + 32 + 42

= 1 + 4 + 9 + 16

= 30

Input : N = 5

Output : 55

Method 1: O(N) The idea is to run a loop from 1 to n and for each i, 1 2 to sum.

# Python3 Program to

# find sum of square

# of first n natural

# numbers

# Return the sum of

# square of first n

# natural numbers

def squaresum(n) :

# Iterate i from 1

# and n finding

# square of i and

# add to sum.

sm = 0

for i in range(1, n+1) :

sm = sm + (i * i)

return sm

# Driven Program

n = 4

Similar questions