Evaluation of e^x with series expansion My code calculates \$e^x\$ with series expansion. Is there any way to make it shorter and cleaner?

#lang racket
; evaluate e^x with series expansion, use first 10 terms.

(define (exp x)
  (letrec ([f1 (lambda (n cx cn)
                 ;(writeln (list n cx cn))
                 (if (&gt;= n 10)
                     0
                     (+ (/ cx cn) (f1 (+ n 1) (* cx x) (* cn (+ n 1))))))])
    (+ 1 (f1 1 x 1))
    )
  )

(letrec ([N (read)]
         [rd (lambda (n)
               (unless (zero? n)
                       (define x (read))
                       (writeln (exp x)) (rd (- n 1))))])
  (rd N))
General Programming

Using built the built in exponent function from racket/base and referencing Euler's Number from math/base would probably reduce the likelihood of bugs; increase speed; and allow programming at a higher level of abstraction.

An alternative to read is the GUI function get-text-from-user in racket/gui/base.


Example Code
#lang racket

(require (only-in math/base
                  euler.0)
         (only-in racket/gui/base
                  get-text-from-user))

(define (get-power-of-e)
  (define x (string-&gt;number
             (get-text-from-user &quot;Power of e&quot;
                                 &quot;provide exponent&quot;)))
  (expt euler.0 x))