Fibonacci in Groovy

Published on 18 October 2018 (Updated: 25 July 2023)

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.

Current Solution

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.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.