- REG x : input
- REG 0 : input value x
- REG 1 : numerator pk
- REG I : previous numerator pk-1
- LBL 3 : entry point
- LBL .3 : local label
- REG y : denominator qk
- REG x : numerator pk
Rev.1.1 Dec. 2 2012
Fractional approximation
001-41,21, 3 LBL 3
002- 36 ENTER
003- 36 ENTER
004- 44 0 STO 0
005- 0 0
006- 44 25 STO I
007- 1 1
008- 44 1 STO 1
009-41,21,.3 LBL .3
010- 33 R↓
011- 33 R↓
012- 43 44 INT
013-45,20, 1 RCL× 1
014-45,40,25 RCL+ I
015-42, 4, 1 x<> 1
016- 44 25 STO I
017- 34 x<>y
018- 42 44 FRAC
019- 15 1/x
020- 45 1 RCL 1
021-45,10, 0 RCL÷ 0
022-42, 7, 0 FIX 0
023- 43,34 RND
024-42, 7, 9 FIX 9
025- 36 ENTER
026- 36 ENTER
027- 45 1 RCL 1
028- 31 R/S
029- 10 ÷
030-42,20, 0 RCL× 0
031- 1 1
032- 30 -
033-43,30, 0 TEST 0
034- 22 .3 GTO .3
035- 34 x<>y
036- 45 1 RCL 1
037- 43 32 RTN
Operation : π GSB C
Result at each R/S
order 0 1 2 3 4 X 3 22 333 355 104348 Y 1 7 106 113 33215
Franctional approximation of π
Fractional approximation program for the HP-32sII
Fractional approximation program for the HP-35S
Fractional approximation program for the HP-42S
Find the nearest fraction in the E24 numbers