Question: write in Java, please. Directions and example A prime number is a number that is only divisible by itself and 1. Write a program that
Directions and example A prime number is a number that is only divisible by itself and 1. Write a program that prompts the user for a number n and then displays the first n prime numbers. If the user enters a negative value for n, display the message Error: n cannot be negative. Hint: you probably want to use nested loops. An example is shown below: What is the value of n? 5 2 3 5 7 11 What is the value of n? -4 Error: n cannot be negative
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
