Computer Science, asked by swarnimamishra196, 9 months ago

write a java program that checks if the numbers between 10 to 15 are prime or not and displays them.

Answers

Answered by anindyaadhikari13
4

Question:-

Write a java program that checks if the numbers between 10 to 15 are prime or not and displays them.

Code:-

class x

{

static boolean isPrime(int n)

{

int c=0;

for(int i=1;i<=n;i++)

{

if(n%i==0)

c++;

}

return (c==2);

}

static void main()

{

for(int i=10;i<=15;i++)

{

if(isPrime(i))

System.out.print(i+" ");

}

}

}

Similar questions