Prime_No_cpp
#include<simplecpp>
main_program{
int n; cin>>n;
int divisor = 2;
bool divisor_found = false; // No divisor is found
// Check from all the way from 2 to n-1
// If any number divides n set divisor_found to true
repeat(n-2){
if (n % divisor == 0) divisor_found = true;
divisor += 1;
}
if (!divisor_found) cout<<"Prime.\n";
else cout<<"Composite.\n";
}
Comments
Post a Comment