Puppet Function: math::fibonacci::binet

Defined in:
functions/fibonacci/binet.pp
Function type:
Puppet Language

Summary

Calculate the fibonacci sequence for the given number using binet method

Overview

math::fibonacci::binet(Numeric $n)Numeric
Note:

The input value maxes out at 27 because it takes too long to calclulate

Note:

Example of how to perform this calculation www.wikihow.com/Calculate-the-Fibonacci-Sequence

Parameters:

  • n (Numeric)

Returns:

  • (Numeric)


6
7
8
9
10
11
12
13
# File 'functions/fibonacci/binet.pp', line 6

function math::fibonacci::binet(Numeric $n) >> Numeric {
  $ratio = math::constants(golden_ratio)
  $a = math::exp($ratio, $n)
  $b = (math::exp(1 - $ratio, $n))
  $c = $a - $b
  $d = $c / math::sqrt($n)
  $d.round
}