Fibonacci in Groovy

Published on 18 October 2018 (Updated: 18 October 2018)

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 'please provide a positive integer'
        } else {
            def n = args[0] as Integer
            def first = 0G
            def second = 1G
            println first.class
            (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 Oct 21 2018 14:29:00. The solution was first committed on Oct 18 2018 19:51:09. As a result, documentation below may be outdated.

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.