%%HP: T(3)A(D)F(.);
@ by Kevin Jessup.
DIR
  PMT 0
  I 0
  FV 0
  PV 0
  cf 12
  pf 12
  N 12
  BEG 0
  EI '(1+I/100/cf)^(cf/pf)-1'
  EQ { 'PV*(1+EI)^N+PMT*(1+EI*BEG)*((1+EI)^N-1)/EI+FV' {N I PV PMT FV
     { "RESET" \<< RESET \>> }
     { "BEG" \<< 1 SETBEG \>> }
     { "END" \<< 0 SETBEG \>> } cf pf } }
  RESET
    \<< 0 DUP DUP DUP2 'PMT' STO 'I' STO 'FV' STO 'PV' STO SETBEG 12 DUP DUP
      'N' STO 'pf' STO 'cf' STO "N=PF=CF=12" 2 DISP
    \>>
  SETBEG
    \<< DUP 'BEG' STO
      IF
      THEN "BEGIN"
      ELSE "END"
      END " mode" + "" 2 DISP 1 DISP 1 FREEZE
    \>>
  TVM { 'PV*(1+EI)^N+PMT*(1+EI*BEG)*((1+EI)^N-1)/EI+FV' { N I PV PMT FV
      { "RESET" \<< RESET \>> }
      { "BEG" \<< 1 SETBEG \>> }
      { "END" \<< 0 SETBEG \>> } cf pf } }
END
