Question: Write in Java Program You are to write a program that finds all the prime numbers between 1 and 100. Recall that a positive integer
Write in Java Program
You are to write a program that finds all the prime numbers between 1 and 100. Recall that a positive integer is prime if it is divisible by only one and itself. Thus 1, 2, 3, and 5 are primes, but 4 and 6 are not. Hint 1: the mod operator (%) returns the remainder after division. So, 25%2 is 1,8%3 is 2, etc. Hint 2: Use a for loop to generate the possible primes (values from 1 to 100), then for each possible prime use a nested loop to check for "possible divisors. Your output should appear as: The prime numbers between 1 and 100 are: 1, 2, 3, 5, 7, ..... Obviously, you must print the remaining primes where I have shown the dots" above. It will probably take more than one line to print all the primes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
