Click here to Skip to main content
15,947,958 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Soit N dans N.
Écrire une fonction donnant la somme des entiers de [1,N[ divisibles par 3 ou 5.

Translation:
Let N be in N.
Write a function giving the sum of the integers of [1,N[ divisible by 3 or 5.


my answer was:
Python
N=eval(input("enter a number:"))
s=0
for i in range(1, N):
    if i%3==0 and i%5==0 :
        s=s+i
        print(s)
    else:


What I have tried:

i dont know what to write in the else part
Posted
Updated 18-Dec-23 15:44pm
v3

First, you don't have to specify an else if there's nothing to do outside of the conditions you've been given.

Next, the program spec says
Quote:
Write a function giving the sum of the integers of [1,N] divisible by 3 or 5.
You might want to look a little closer at your code to see if your code matches that condition.
 
Share this answer
 
Comments
CPallini 19-Dec-23 2:02am    
5.
Quote:
i dont know what to write in the else part
First, you have to fix your ifcondition. As suggested, look again at the requirement. See if your code complies.
The else part is optional, if you don't need it, then omit it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900