Write a program to input the number and check the number weather it is prime or not | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program to input the number and check the number weather it is prime or not

A number is said to be prime if it is divisible by 1 and itself

1st Feb 2020, 1:00 PM
Ayush
4 Answers
17th Feb 2020, 12:11 AM
Indira
Indira - avatar
+ 2
Can you show us you attempt ? Also, don't forget to include your programming language in the tags.
1st Feb 2020, 1:03 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
See this code https://www.programiz.com/c-programming/examples/prime-number Read and try write your code.
1st Feb 2020, 1:05 PM
Pedro H.J
Pedro H.J - avatar
0
//in Java Public void searchPrim(int number) { //2, because 1 is always true Int i =2 while (i<= number && number % i != 0) { i++; } if (number == i) { System.out.println("Prime!") } else { System.out.println(number +"has smallest divisor" +i) ; }
2nd Feb 2020, 12:22 AM
Alisa Jääkarhu
Alisa Jääkarhu - avatar