- /*************************************************************************
- > File Name: bogus_prime.cpp
- ************************************************************************/
- #include<iostream>
- #include<stdlib.h>
- int po2(int n)
- {
- int sum = 1;
- for(int i = 1; i<=n; i++)
- {
- sum *= 2;
- }
- return sum;
- }
- using namespace std;
- int main(void)
- {
- string a;
- int b;
- cin >> a;
- b=atoi(a.c_str());
- if(po2(b-1)%b == 1)
- cout<<b << " " << "is a prime" << endl;
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/0705201512510.html
来源: http://www.codesnippet.cn/detail/0705201512510.html