Fibonacci in Elvish

Published on 08 January 2025 (Updated: 08 January 2025)

Welcome to the Fibonacci in Elvish page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

if (> 1 (count $args)) {
  echo "Usage: please input the count of fibonacci numbers to output"
  exit 1
}

try {
  var r = (+ $args[0] 1) # Hacky, but it tries to add the argument with one.
} catch { # If it fails, the value is not a number.
  echo "Usage: please input the count of fibonacci numbers to output"
  exit 1
}

var a = 0
var b = 1
var c = 0

for i [(range 1 (+ $args[0] 1))] {
  set c = (+ $a $b)
  set a = $b
  set b = $c
  echo $i': '$a
}

Fibonacci in Elvish 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.