Skip to content

Instantly share code, notes, and snippets.

@Hardtack
Created April 6, 2013 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hardtack/5327410 to your computer and use it in GitHub Desktop.
Save Hardtack/5327410 to your computer and use it in GitHub Desktop.
(begin
(define
(read-int)
(int (read) Null)
)
(define
(! x)
(if (> x 1)
(* x (! (- x 1)))
1
)
)
(define
(C n r)
(/
(! n)
(*
(! r)
(! (- n r))
)
)
)
(define (pascal-n n)
(begin
(define
(f x)
(if
(>= x 0)
(begin
(display (C n x))
(display ' ')
(f (- x 1))
)
Null
)
)
(f n)
(newline)
)
)
(define (print-white n) (if (> n 0) (begin (display ' ') (print-white (- n 1))) Null))
(define (pascal n)
(begin
(define (f x)
(if
(> x 0)
(begin
(print-white x)
(pascal-n (- n (- x 1)))
(f (- x 1))
)
Null
)
)
(f n)
)
)
(display 'Enter : ')
(define N (read-int Null))
(pascal N)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment