Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Filtering Numbers in a Loop | Loops
Java Basics
course content

Course Content

Java Basics

Java Basics

1. Getting Started
2. Basic Types, Operations
3. Loops
4. Arrays
5. String

book
Challenge: Filtering Numbers in a Loop

Task
test

Swipe to begin your solution

Find the sum of all numbers from 1 to n, excluding those that are divisible by 3 or 5.

  1. Write a for loop that runs from 1 to n.
  2. Inside the loop, check if the current number is divisible by 3 or 5.
  3. If the number is not divisible by 3 or 5, add it to the sum variable.

Solution

java

solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 8
toggle bottom row

book
Challenge: Filtering Numbers in a Loop

Task
test

Swipe to begin your solution

Find the sum of all numbers from 1 to n, excluding those that are divisible by 3 or 5.

  1. Write a for loop that runs from 1 to n.
  2. Inside the loop, check if the current number is divisible by 3 or 5.
  3. If the number is not divisible by 3 or 5, add it to the sum variable.

Solution

java

solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 8
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt