Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Content added Content deleted
m (J: simplify tacit version) |
m (J: make description match updated code) |
||
Line 447: | Line 447: | ||
│3 10│3 7 7│3 7 23 1 2│3 7 357│3 7 2857│3 7 142857│3 7 476190 3│3 7 7142857│ |
│3 10│3 7 7│3 7 23 1 2│3 7 357│3 7 2857│3 7 142857│3 7 476190 3│3 7 7142857│ |
||
└────┴─────┴──────────┴───────┴────────┴──────────┴────────────┴───────────┘</lang> |
└────┴─────┴──────────┴───────┴────────┴──────────┴────────────┴───────────┘</lang> |
||
This tacit version first produces the answer with a trailing ∞ (represented by _ in J) which is then removed by the last operation (} |
This tacit version first produces the answer with a trailing ∞ (represented by _ in J) which is then removed by the last operation (_1 1 ,@}. ...). A continued fraction can be evaluated using the verb ((+%)/) and both representations produce equal results, |
||
<lang j> 3 7 =&((+ %)/) 3 7 _ |
<lang j> 3 7 =&((+ %)/) 3 7 _ |
||
1</lang> |
1</lang> |