A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Fibonacci in Racket page! Here, you'll find the source code for this program as well as a description of how the program works.
#lang racket
;; A naive iimplementation of fibonacci
(define (fib n)
(cond
[(<= n 2) 1]
[else
(+ (fib (- n 1)) (fib (- n 2)))]))
(define (fibonacci n)
(cond
[(or (not n) (< n 0)) (display "Usage: please input the count of fibonacci numbers to output")]
[else
(for ([i (in-range 1 (add1 n))])
(displayln (string-append (number->string i) ": " (number->string (fib i)))))
]))
(fibonacci
(string->number
(cond
[(vector-empty? (current-command-line-arguments)) ""]
[else (vector-ref (current-command-line-arguments) 0)]
)
)
)
Fibonacci in Racket was written by:
If you see anything you'd like to change or update, please consider contributing.
Note: The solution shown above is the current solution in the Sample Programs repository as of May 10 2022 22:08:48. The solution was first committed on Oct 31 2019 22:31:00. As a result, documentation below may be outdated.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.