Question

Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print...

Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print the numbers which are a multiple of 3.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Main {

    public static void main(String[] args) {

        // prints numbers from 0 to 1,000,000

       for(int i = 0; i < 1000000; i++) {

           // prints only those which are multiple of 3

            if(i % 3 == 0) {

               System.out.println(i);

           }

        }

   }

}

ABOVE CODE WILL OUTPUT THE NUMBERS IN THE GIVEN RANGE WHICH ARE ONLY MULTIPLE OF 3.

FOR HELP PLEASE COMMENT.
THANK YOU.

Add a comment
Know the answer?
Add Answer to:
Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT