Answer the question
In order to leave comments, you need to log in
I can not understand the terms of the problem?
Good afternoon!
I am taking an entrance exam on the stepic platform , and in the test tasks I could not understand the essence of the task:
Write a program that reads (from standard input) a natural number 1≤n≤20 and outputs (to standard output) the sum of the squares of all integers from the interval from 1 up to n that are not divisible by 3.
Sample Input 1:
2
Sample Output 1:
5
Sample Input 2:
4
Sample Output 2:
21
I suggested that you need to select all natural numbers up to the nth that are divisible by 3 without a remainder and add their squares.
n = int(input())
s = 0
if 1 <= n <= 20:
for i in range(n):
if i % 3 == 0:
s += i ** 2
print(s)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question