0
Multiples question....what did i do wrong
8 Réponses
+ 1
You should be using the modulo operator to see what are multiples. Right now, your if statement is just looking at what number divided by 3 or 5 equals 0.
But the only answer to the question mathematically is 0. So you need to rethink your logic in finding what numbers have a REMAINDER of 0 when decided by 3 or 5.
So you're close, just have your operators a bit off.
+ 1
Thank you very much .... :)
0
Can you please elaborate on what you are trying to do? You don't have any comments and your code has very generic variable names.
0
Multiples community question
0
I don't know what community question you are referring to and you don't have the reference in the comments of your code either.
Don't assume everyone will know what you are talking about so make sure to always leave references, or at least make your code readable to outside readers.
0
You need to calculate the sum of all the multiples of 3 or 5 below a given number.
Task:
Given an integer number, output the sum of all the multiples of 3 and 5 below that number.
If a number is a multiple of both, 3 and 5, it should appear in the sum only once.
Input Format:
An integer.
Output Format:
An integer, representing the sum of all the multiples of 3 and 5 below the given input.
Sample Input:
10
Sample Output:
23
0
Sorry
0
No problem. 👍🏾