### G.C.D

need some test cases. getting wrong answer!!

http://ideone.com/Qmwxj
http://www.codechef.com/problems/RECIPE/
If the answer is wrong, you already have test cases.
What you need is coding changes.
ofcourse i need to change code..bt it runs for every test case i enter...so i dont know what change to make unless i see my mistake
I understand the HCF (GCD) code.

But I'm sorry, I've no idea what is going on in `main()`.

Test data for HCF:
 ``` 14520 and 456566 HCF value: 22 115980 and 264450 HCF value: 30 854174 and 196190 HCF value: 46 474360 and 890955 HCF value: 15 882740 and 465704 HCF value: 92 691272 and 47316 HCF value: 12 813917 and 457340 HCF value: 13 646728 and 352944 HCF value: 24 520814 and 130844 HCF value: 14 269047 and 482469 HCF value: 89 51972 and 732360 HCF value: 12 163670 and 526230 HCF value: 10 725760 and 593270 HCF value: 10 429559 and 466778 HCF value: 13 49050 and 60048 HCF value: 18 336826 and 71195 HCF value: 491 191776 and 819312 HCF value: 208 76464 and 155331 HCF value: 27 122190 and 306580 HCF value: 10 336567 and 475076 HCF value: 329 ```

Last edited on
Test case:

 ```1 2 2618 1365```

Expected output:

 `374 195`

 `2 1`

 ``12345`` `````` while(n%m!=0) { m=n%m; n=m; }``````

What is the maximum number of times that loop will execute? The answer is 1. Do you see why?

Edit: typo'd expected output.
Last edited on
Topic archived. No new replies allowed.