Write a program that will find out whether the given number is even or odd. If odd number then find out whether it is prime or not.
Answers
Answered by
0
Answer:
bluej program:
import java.util.*;
class oddprime
{
public static void main()
{
Scanner sc= new Scanner(System.in);
System.out.println("enter an integer");
int n=sc.nextInt(),c=0;
if (n%2!=0)
{
for (int i=1;i<=n;i++)
{
if (n%i==0)
{
c++;
}
}
}
if(c==2)
System.out.println("The number is odd and prime");
else
System.out.println("The number is not prime");
}
}
Explanation:
Similar questions
Social Sciences,
5 months ago
Psychology,
5 months ago
Hindi,
5 months ago
English,
10 months ago
Geography,
1 year ago
Math,
1 year ago
Math,
1 year ago