V
V
varnak522018-02-11 17:21:08
Python
varnak52, 2018-02-11 17:21:08

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)

But unfortunately, I did not correctly understand the conditions of this task and how I can not understand what is required of me.
Can you please tell me what is required for this task?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question