Marvin Villamizar
/
EJEMPLO_II_11_AGO_2017
dasd
main.cpp
- Committer:
- dimmu8410
- Date:
- 2018-07-06
- Revision:
- 0:81cf99bfa3ca
File content as of revision 0:81cf99bfa3ca:
#include "mbed.h" DigitalOut led(LED2); DigitalIn push(PC_13); Serial pc(USBTX,USBRX); int count,read,prim; int primo(int number); int main() { while(1) { read=push.read(); if(read==0) { count ++; wait(0.3); } pc.printf("Numero: %d\n\r",count); wait(0.5); prim=primo(count); if(prim==0) { led=0; } else { led=1; } } } int primo(int number) { int nc=0; int res=0; for(int c=1;c<=number;c++) { res=number%c; if(res==0) nc++; if(nc>2) break; } if(nc==2) {return 1;} else {return 0;} }