Computer Science, asked by aashish504, 4 months ago

Write a program to check a number whether it is prime or composite.​


aashish504: please give answer

Answers

Answered by Oreki
2

Algorithm:

  • Accepting the number.
  • Checking the number is a prime number or not by iterating halfway to the number and checking if any number in that range is divisible by the number.  
  • If it is divisible then returns false else true.
  • Finally displaying the output based on the value returned by the method.
Attachments:
Similar questions