karlangadas

4 Fuerza bruta

Jan 15th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.     int n, primo=1;
  5.     scanf("%d",&n);
  6.     if (n<2)
  7.         primo=0;
  8.     for (int i=2;i<n;i++)
  9.         if ((n%i)==0){
  10.             primo=0;
  11.             break;
  12.         }
  13.    
  14.     if (primo)
  15.         printf("Es primo\n");
  16.     else
  17.         printf("No es primo\n");
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment