| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
One for you math gurus...
I'm having problems coming up with an algorythm to solve the following problem:
I need to find three fractions that add up to exactly 1. They each must have a single digit numerator and a double digit denominator. I can only use the digits 1-9 and each digit can only be used once. Example: 1/23 + 4/56 + 7/89 = ??? or 9/12 + 8/34 + 7/56 = ??? HELP! |
|
#2
|
|||
|
|||
|
Try this:
1. Start 2. Take three var, iA,iB and iC. a. Choose any digit and assign it to iA. b. Choose digit from the remaining eight numbers and assign to iB c. Repeat step 2b with remaining seven digits and assign to iC. 3. Form number of iB and iC as iC*10 + iB 4. Divide iA by product of step3 to get fraction. 5. Repeat steps 2 - 4 with remaining six numbers and add the resultant to step 4. 6. Repeat step five with remaining 4 numbers. 7. If sum is 1 then print "Success" and goto step 8 else go to step 2. 8. Stop. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > One for you math gurus... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|