PasteRack.org
Paste # 16705
2019-03-09 20:01:36

Fork as a new paste.

Paste viewed 356 times.


Embed:

recursion to sum

  1. #lang racket
  2.  
  3. (define calculateKey
  4.   (lambda (w n)
  5.       (if (positive? n)
  6.           (if (empty? w)
  7.               1
  8.               (+
  9.                (ctv (list-ref w (- (length w) 1)))
  10.                (* 29 (calculateKey (take w (- (length w) 1)) 1)))
  11.          )
  12.           (*
  13.            (+
  14.             (ctv (list-ref w (- (length w) 1)))
  15.             (* 29 5413))
  16.            (calculateKey (take w (- (length w) 1)) 1))
  17.       )
  18.  
  19.  ))

=>