Telaryon

Relatív prímszám

Mar 18th, 2017
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int lnkofv(int a, int b);
  6.  
  7. int main(void){
  8.  
  9.     int N;
  10.     int db = 0;
  11.     int lnko;
  12.     int a;
  13.     int b;
  14.  
  15.     scanf("%d", &N);
  16.     srand (time(0));
  17.     while(db <= N){
  18.         a = rand()% 100+1;
  19.         b = rand()% 100+1;
  20.         lnko = lnkofv(a, b);
  21.         if(lnko == 1) {
  22.             db++;
  23.             printf("%d %d", a, b);
  24.         }
  25.     }
  26.     return 0;
  27. }
  28.  
  29. int lnkofv(int a, int b){
  30.     int temp;
  31.  
  32.     while(a>b){
  33.         temp = b;
  34.         b = a%b;
  35.         a = temp;
  36.     }
  37.     return a;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment