(42S) Continuous Fractions - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (42S) Continuous Fractions (/thread-14417.html) (42S) Continuous Fractions - Eddie W. Shore - 01-26-2020 01:52 PM Let x be a real number. Then x can be represented by the fraction: x = n_1 + 1/(n_2 + 1/(n_3 + 1/(n_4 + 1/(n_5 + ...)))) The above form is known as a continuous fraction, which can either have a finite set of terms or infinite set of terms. In short form, continuous fractions can be written in a vector form: x = [ n_1, n_2, n_3, n_4, n_5, ... ] If you are given a continuous fraction (n_1, n_2, etc.), you can calculate x with the following keystrokes, starting with the last term n_k and working left to n_1: RPN Calculators: 1. Start by entering n_k, then press [ 1/x ] 2. Loop: For each n_m for 1 < m < k: enter n_m, [ + ], [ 1/x ] 3. For n_1: Enter n_1, [ + ] Remember, we are working leftwards. The program CF for the HP 42S (and Swiss Micros DM42 and Free42 emulator) calculates the value of a continued fraction. Instructions: 1. Run CF ( [ XEQ ] (CF) ) 2. Enter n_k, press (LAST) 3. For each n_m for 1 < m < k, enter n_m, press (MID) 4. For n_1, enter n_1, press (1ST). You get the result. HP 42S/DM42/Free 42 Program CF: Code: ``` 00 {56-Byte Prgm} 01 LBL "CF" 02 LBL 04 03 CLMENU 04 "LAST" 05 KEY 1 GTO 01 06 "MID" 07 KEY 2 GTO 02 08 "1ST" 09 KEY 3 GTO 03 10 MENU 11 LBL 00 12 STOP 13 GTO 00 14 LBL 01 15 1/X 16 GTO 04 17 LBL 02 18 + 19 1/X 20 GTO 04 21 LBL 03 22 +  23 CLMENU 24 EXITALL 25 RTN 26 END``` Blog Link: http://edspi31415.blogspot.com/2020/01/hp-42s-casio-fx-260-solar-continued.html