Course Content
Java Basics
Java Basics
Challenge: Filtering Numbers in a Loop
Task
Swipe to begin your solution
Find the sum of all numbers from 1 to n
, excluding those that are divisible by 3 or 5.
- Write a
for
loop that runs from 1 ton
. - Inside the loop, check if the current number is divisible by 3 or 5.
- If the number is not divisible by 3 or 5, add it to the
sum
variable.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 8
Challenge: Filtering Numbers in a Loop
Task
Swipe to begin your solution
Find the sum of all numbers from 1 to n
, excluding those that are divisible by 3 or 5.
- Write a
for
loop that runs from 1 ton
. - Inside the loop, check if the current number is divisible by 3 or 5.
- If the number is not divisible by 3 or 5, add it to the
sum
variable.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 8
Switch to desktop for real-world practiceContinue from where you are using one of the options below