|
كليات المجموعة الرياضية (الهندسة - الحاسبات والمعلومات - التجارة & التجارة إنجلش - الفنون التطبيقية والجميلة) |
|
أدوات الموضوع | انواع عرض الموضوع |
#1
|
|||
|
|||
![]()
#include <iostream>
#include <cmath> using namespace std; int main() {int n; bool x; cout<<"enter number to check"; cin>> n; if(n==2) cout<<n<<"is prime"; else if((n%2)==0) cout<<n<<"is not prime"; else if(n==0||n==1) cout<<n<<"is not prime"; else for(int i=3;i<=sqrt(n);i+=2){ x=false ; if((n%i)==0) x=true ; }if(x==true) cout<<n<<"isn't prime"; else cout<<n<<"is prime"; return 0; } |
العلامات المرجعية |
|
|