/***************************************
- 时间:
- 内容:判断一个数为素数
****************************************/
#include<wiringPi.h>
#include<iostream>
using namespace std;
const int BEEP = 1;//BCM 是18 //wPi 是 0
void beepClock(){
while(1){
for(int i=0; i<10; i++){
digitalWrite(BEEP,1);
delay(1);
digitalWrite(BEEP,0);
delay(1);
}
delay(100);
}
}
int main(){
while(-1 == wiringPiSetup()){//使用Wpi模式
cout << "error" << endl;
}
pinMode(BEEP, OUTPUT);
digitalWrite(BEEP,1);
int n;
cin >> n;
for(int i=2; i<n; i++){
if(n%i == 0){
cout << i << "能被" << n << "整除\n";
beepClock();
return false;
}
}
cout << n << "是素数\n";
return 0;
}