Факториал.Хвостовая рекурсия
This commit is contained in:
11
Гарифуллин Марат/hvost_rec.rkt
Normal file
11
Гарифуллин Марат/hvost_rec.rkt
Normal file
@@ -0,0 +1,11 @@
|
||||
#lang racket
|
||||
|
||||
(define (tfact x n)
|
||||
(cond
|
||||
[(equal? n 0) x]
|
||||
[else (tfact (* x n)(- n 1))]))
|
||||
|
||||
(define (fact n)
|
||||
(tfact 1 n))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user