Advertisement
Guest User

Numeros primos

a guest
May 25th, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. main()
  5. {
  6.     int N1,N2,cont1=0,p,c;
  7.     printf ("            --------------------------------------------------------");
  8.     printf ("\n            -_-_-_-_-_--_ Quais sao os numeros primos? _--_-_-_-_-_- \n");
  9.     printf ("            --------------------------------------------------------\n\n\n\n");
  10.     printf (" \n                     _________Informe um numero: " );
  11.     scanf ("%d", &N1);
  12.     printf (" \n                     _________Informe outro numero: " );
  13.     scanf("%d", &N2);
  14.     while(N1 <=0 || N2 <=0)
  15.     {
  16.     printf ("\n\n        ________ Por favor digite um numero inteiro e positivo! ________\n\n");
  17.     printf (" \n                     _________Informe um numero: " );
  18.     scanf ("%d", &N1);
  19.     printf (" \n                     _________Informe outro numero: " );
  20.     scanf("%d", &N2);
  21.     printf(" \n ============================================================================\n\n");
  22.     }
  23.    
  24.    if (N1>N2)
  25.     {  
  26.        
  27.         cont1=0;
  28.          for( c =1; c <= N2; c++)
  29.          {
  30.           if (N2%c==0)
  31.           {
  32.             cont1++;     
  33.           }
  34.             if (cont1==2)
  35.             {
  36.              printf ("Este numero e primo \n %d :", &c);
  37.             };
  38.          }
  39.       c++;
  40.            
  41.        
  42.        
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement