PowerShell/Scripts/list-fibonacci.ps1

24 lines
467 B
PowerShell
Raw Normal View History

2022-09-11 11:57:15 +02:00
<#
2022-09-06 21:42:04 +02:00
.SYNOPSIS
Lists the Fibonacci numbers
.DESCRIPTION
This PowerShell script lists the Fibonacci numbers.
.EXAMPLE
PS> ./list-fibonacci
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
2022-09-02 19:34:22 +02:00
function fibonacci($n) {
if ($n -lt 2) { return 1 }
return (fibonacci($n - 1)) + (fibonacci($n - 2))
}
foreach ($i in 0..100) {
Write-Host "$(fibonacci $i), " -noNewline
}
2022-09-06 21:42:04 +02:00
exit 0 # success