Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2012-09-26 02:45:31.560 nn[731:303] Which numbers do you want to calculate Great Common Divisor?
- 1st=
- 4
- 2012-09-26 02:45:36.777 nn[731:303] 2nd=
- 6
- 2012-09-26 02:45:39.633 nn[731:303] your number is 45 and 66, and gcd is 3
- #import <Foundation/Foundation.h>
- int main (int argc, char *argv[]){
- @autoreleasepool{
- int n1, n2;
- int numerator, denominator, remainder, gcd;
- numerator = 0;
- denominator = 0;
- remainder = 0;
- gcd = 0;
- NSLog(@"Which numbers do you want to calculate Great Common Divisor? n 1st=");
- scanf("%i", &n1);
- NSLog(@"2nd=");
- scanf("%i", &n2);
- numerator = n1;
- denominator = n2;
- while (numerator % denominator != 0){
- remainder = numerator % denominator;
- numerator = denominator;
- denominator = remainder;
- }
- gcd = denominator;
- NSLog(@"your number is %i and %i, and gcd is %i", n1, n2, gcd);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment