home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / mag_discs / volume_8 / issue_08 / puzzles / !EgFrac / EgFrac < prev    next >
Text File  |  1995-02-27  |  1KB  |  51 lines

  1.  
  2.  ⌠>EgFrac
  3. ⌠>John Banks
  4. ⌠>February 1995
  5. "L⌠>Finds partitions of a given fraction into sums of distinct reciprocals
  6. ,⌠
  7. 6G⌠>Not all possibilities are found - some "trivial" near-repetitions
  8. @=⌠>based e.g. on 1/2 = 1/3 + 1/6 and the like are ignored.
  9. JD⌠>Likewise only the first partition where the two lowest numbers
  10. T!⌠>are identical is considered
  11. ^⌠
  12. h*Φ"Numerator, Denominator? "Onum%,Oden%
  13. r%Φ"Max denom to be allowed? "maxd%
  14. |/±"Smallest number of terms considered is 2"
  15. åΦ"Largest required "maxlev%
  16. É▐row%(maxlev%)
  17. Ü iter%=0
  18. ñ≥find(Onum%,Oden%,2,1)
  19. «3τiter%:±'iter%;" partitions found":ï:±'"Failed"
  20. ╕
  21. ┬α
  22. ╠
  23. ╓
  24. α▌≥find(n%,d%,i%,depth%)
  25. Ω/τ(d% âi%)=0:τ(n% âi%)=0:d%=d% üi%:n%=n% üi%
  26. ⌠Ωà
  27. ■εàΩ:τƒ<>17:ß:ï:α
  28. τdepth%>maxlev%:ß
  29. ⌡
  30. τ n%*i%=d% î
  31. &row%(depth%)=i%
  32. 0 πQ%=1╕depth%:±row%(Q%),;:φ:±
  33. :i%+=1:iter%+=1
  34. D═
  35. Nȕd%>n%*i%
  36. X    i%+=1
  37. bτi%>maxd%:ß
  38. lτ n%*i%=d% î
  39. vrow%(depth%)=i%
  40. Ç πQ%=1╕depth%:±row%(Q%),;:φ:±
  41. èi%+=1:iter%+=1
  42. ö═
  43. ₧╬
  44. ¿row%(depth%)=i%
  45. ▓'≥find(n%*i%-d%,d%*i%,i%+1,depth%+1)
  46. ╝    i%+=1
  47. ╞/²(i%>maxd%) ä (n%*i%)>d%*(maxlev%-depth%+1)
  48. ╨ß
  49. ┌
  50. Σ
  51.