Факториал.Хвостовая рекурсия

This commit is contained in:
2022-05-12 19:05:00 +03:00
parent f27315172d
commit 1883662b9a
2 changed files with 21 additions and 0 deletions

View 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))