A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by rzuckerm
Welcome to the Fibonacci in Groovy page! Here, you'll find the source code for this program as well as a description of how the program works.
class Fibonacci {
static void main(String[] args) {
if (args.length < 1 || !args[0].isInteger()) {
println 'Usage: please input the count of fibonacci numbers to output'
} else {
def n = args[0] as Integer
if (n > 0) {
def first = 0G
def second = 1G
(1..n).each {
second += first
first = second - first
println "$it: $first"
}
}
}
}
}
Fibonacci in Groovy 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 Jul 25 2023 18:37:12. The solution was first committed on Oct 18 2018 19:51:09. 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.