Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. /*Nombre: primos.c
  2. Sinopsis: calcula los primos entre 1 y 100.
  3. Autor: yo, que soy to prah (Víctor).*/
  4.  
  5. #include<stdio.h>
  6.  
  7. int resto, numero,i,primo;
  8.  
  9. int main(){
  10. for(numero=1;numero<=100;numero++){
  11.   primo=1;
  12.   for(i=(numero-1);i>1;i--){
  13.     resto=(numero%i);
  14.     if(resto==0){
  15.       primo=0;
  16.       break;
  17.     }
  18.   }  
  19.   if (primo==1)
  20.   printf("%d es primo\n",numero);
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement