Guest User

Untitled

a guest
Jan 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 2012-09-26 02:45:31.560 nn[731:303] Which numbers do you want to calculate Great Common Divisor?
  2.  
  3. 1st=
  4.  
  5. 4
  6.  
  7. 2012-09-26 02:45:36.777 nn[731:303] 2nd=
  8.  
  9. 6
  10.  
  11. 2012-09-26 02:45:39.633 nn[731:303] your number is 45 and 66, and gcd is 3
  12.  
  13. #import <Foundation/Foundation.h>
  14.  
  15. int main (int argc, char *argv[]){
  16. @autoreleasepool{
  17. int n1, n2;
  18. int numerator, denominator, remainder, gcd;
  19. numerator = 0;
  20. denominator = 0;
  21. remainder = 0;
  22. gcd = 0;
  23.  
  24. NSLog(@"Which numbers do you want to calculate Great Common Divisor? n 1st=");
  25. scanf("%i", &n1);
  26. NSLog(@"2nd=");
  27. scanf("%i", &n2);
  28.  
  29. numerator = n1;
  30. denominator = n2;
  31.  
  32. while (numerator % denominator != 0){
  33. remainder = numerator % denominator;
  34. numerator = denominator;
  35. denominator = remainder;
  36. }
  37.  
  38. gcd = denominator;
  39. NSLog(@"your number is %i and %i, and gcd is %i", n1, n2, gcd);
  40. }
  41. return 0;
  42. }
Add Comment
Please, Sign In to add comment