Write a program to check a number whether it is prime or composite.
aashish504:
please give answer
Answers
Answered by
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
Math,
1 month ago
Science,
1 month ago
Hindi,
1 month ago
Math,
3 months ago
History,
3 months ago
Chemistry,
9 months ago
Social Sciences,
9 months ago
Social Sciences,
9 months ago