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 >
Wrap
Text File
|
1995-02-27
|
1KB
|
51 lines
⌠>EgFrac
⌠>John Banks
⌠>February 1995
"L⌠>Finds partitions of a given fraction into sums of distinct reciprocals
,⌠
6G⌠>Not all possibilities are found - some "trivial" near-repetitions
@=⌠>based e.g. on 1/2 = 1/3 + 1/6 and the like are ignored.
JD⌠>Likewise only the first partition where the two lowest numbers
T!⌠>are identical is considered
^⌠
h*Φ"Numerator, Denominator? "Onum%,Oden%
r%Φ"Max denom to be allowed? "maxd%
|/±"Smallest number of terms considered is 2"
åΦ"Largest required "maxlev%
É▐row%(maxlev%)
Üiter%=0
ñ≥find(Onum%,Oden%,2,1)
«3τiter%:±'iter%;" partitions found":ï:±'"Failed"
╕
┬α
╠
╓
α▌≥find(n%,d%,i%,depth%)
Ω/τ(d% âi%)=0:τ(n% âi%)=0:d%=d% üi%:n%=n% üi%
⌠Ωà
■εàΩ:τƒ<>17:ß:ï:α
τdepth%>maxlev%:ß
⌡
τ n%*i%=d% î
&row%(depth%)=i%
0 πQ%=1╕depth%:±row%(Q%),;:φ:±
:i%+=1:iter%+=1
D═
Nȕd%>n%*i%
X i%+=1
bτi%>maxd%:ß
lτ n%*i%=d% î
vrow%(depth%)=i%
Ç πQ%=1╕depth%:±row%(Q%),;:φ:±
èi%+=1:iter%+=1
ö═
₧╬
¿row%(depth%)=i%
▓'≥find(n%*i%-d%,d%*i%,i%+1,depth%+1)
╝ i%+=1
╞/²(i%>maxd%) ä (n%*i%)>d%*(maxlev%-depth%+1)
╨ß
┌
Σ