Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Content added Content deleted
m (J: make description match updated code) |
m (→version 3) |
||
Line 506: | Line 506: | ||
│0 2│3│2 1 7│1 5 2│3 7│1 2 2 2 2 2 2 2 2 2 6 1 2 4 1 1 2 _│_2 25 1 2│ |
│0 2│3│2 1 7│1 5 2│3 7│1 2 2 2 2 2 2 2 2 2 6 1 2 4 1 1 2 _│_2 25 1 2│ |
||
└───┴─┴─────┴─────┴───┴───────────────────────────────────┴─────────┘</lang> |
└───┴─┴─────┴─────┴───┴───────────────────────────────────┴─────────┘</lang> |
||
==== version 3 ==== |
|||
translation of python: |
|||
<lang J>r2cf=:3 :0 |
|||
'n1 n2'=. y |
|||
r=.'' |
|||
while.n2 do. |
|||
'n1 t1 n2'=. n2,(0,n2)#:n1 |
|||
r=.r,t1 |
|||
end. |
|||
)</lang> |
|||
Example: |
|||
<lang J> r2cf each 1 2;3 1;23 8;13 11;22 7;14142136 10000000;_151 77 |
|||
┌───┬─┬─────┬─────┬───┬─────────────────────────────────┬─────────┐ |
|||
│0 2│3│2 1 7│1 5 2│3 7│1 2 2 2 2 2 2 2 2 2 6 1 2 4 1 1 2│_2 25 1 2│ |
|||
└───┴─┴─────┴─────┴───┴─────────────────────────────────┴─────────┘</lang> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |