Advertisement
VitorMDias

gold

Sep 1st, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <ctype.h>
  6.  
  7. int primo(n)
  8. {
  9.     int i , p;
  10.     for(i = 1; i <= n ; i++)
  11.         {
  12.             if ((n % i) == 0)
  13.                 p ++;
  14.         }
  15.     if(p == 2)
  16.         return 1;
  17. }
  18.  
  19. int main()
  20. {
  21.     int n , r1 , r2;
  22.     int aux1 , aux2 , flag=0;
  23.     do
  24.     {
  25.         scanf("%d" , &n);
  26.         if(n == 0)
  27.             break;
  28.         if(n % 2 != 0)
  29.             printf("erro\n");
  30.         else
  31.         {
  32.             aux1 = n;
  33.             aux2 = 0;
  34.             while(flag == 0)
  35.             {
  36.                 aux1--;
  37.                 aux2++;
  38.                 if(primo(aux1) == 1 && primo(aux2) == 1)
  39.                     flag = 1;
  40.             }
  41.             printf("%d %d\n" , aux1 , aux2);
  42.         }
  43.        
  44.        
  45.     }while(n != 0);
  46.    
  47.    
  48.    
  49.    
  50.    
  51.    
  52.    
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement