Focus on the fact that the expected output is a single number: the sum.
A simple way to solve it is to look at each candidate, from the smallest to the largest. If it fits the constraints, add it to a variable that contains the partial result. A pseudo-code that implements this idea:
Seja n um número inteiro
Leia n
Seja soma um inteiro com valor 0
Seja i um inteiro com valor 1
Enquanto i for menor do que n:
Se i é divisível por 3 ou i é divisível por 5:
soma <- soma + i
i <- i + 1
Imprima soma
There is room for optimizations. For example: is it necessary to look at even numbers? And primes? For simplicity’s sake, I left that sort of thing out of the answer, but it’s a good exercise to think about it.
Why my question was negative?
– Guilherme Santana De Souza
I took the liberty of simplifying your question to quote just the relevant part: the desired algorithm and the constraints. I also traded "multiples of 3 and 5" for "multiples of 3 or 5," which I think is what you really need. Otherwise, let me know.
– Pablo Almeida
I accept the edition.
– Guilherme Santana De Souza
I just corrected the title.
– Guilherme Santana De Souza