2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,26 +1,9 @@
|
|||
function fib ($n) {
|
||||
if ($n -eq 0) { return 0 }
|
||||
if ($n -eq 1) { return 1 }
|
||||
|
||||
$m = 1
|
||||
if ($n -lt 0) {
|
||||
if ($n % 2 -eq -1) {
|
||||
$m = 1
|
||||
} else {
|
||||
$m = -1
|
||||
}
|
||||
|
||||
$n = -$n
|
||||
function FibonacciNumber ( $count )
|
||||
{
|
||||
$answer = @(0,1)
|
||||
while ($answer.Length -le $count)
|
||||
{
|
||||
$answer += $answer[-1] + $answer[-2]
|
||||
}
|
||||
|
||||
$a = 0
|
||||
$b = 1
|
||||
|
||||
for ($i = 1; $i -lt $n; $i++) {
|
||||
$c = $a + $b
|
||||
$a = $b
|
||||
$b = $c
|
||||
}
|
||||
|
||||
return $m * $b
|
||||
return $answer
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue