## FibGen(x, y, numSeq)

##### Last updated June 26, 2002

**Version:** 1 |
**Requires:** CF5 |
**Library:** MathLib

**Description:**

Returns the Fibonacci sequence to n places given a starting point of x and y (each integer is the sum of the two previous integers). Note that the function will also calculate the sequence for non-Fibonacci numbers. Based on FibCalc() by Phillip B. Holmes (pholmes@mediares.com).

**Return Values:**

Returns a comma-delimited list of numbers.

**Example:**

```
<cfoutput>
#FibGen(0,1,10)#<BR>
#FibGen(1,1,10)#
</cfoutput>
```

**Parameters:**

Name | Description | Required |
---|---|---|

x | First number in the sequence. | Yes |

y | Second number in the sequence. | Yes |

numSeq | Number of elements to generate for the sequence. | Yes |

**Full UDF Source: **

```
/**
* Returns the Fibonacci sequence to n places given a starting point of x and y.
*
* @param x First number in the sequence. (Required)
* @param y Second number in the sequence. (Required)
* @param numSeq Number of elements to generate for the sequence. (Required)
* @return Returns a comma-delimited list of numbers.
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1, June 26, 2002
*/
function FibGen(x,y,numSeq){
var sequence = arrayNew(1);
var total = x+y;
var i=1;
sequence[1] = x;
sequence[2] = y;
while (i LTE numSeq-2) {
total=(x+y);
ArrayAppend(sequence, total);
x=y;
y=total;
i=i+1;
}
return ArrayToList(sequence, ',');
}
```

blog comments powered by Disqus
### Search CFLib.org

### Latest Additions

Kevin Cotton added

date2ExcelDate

May 5, 2016

Raymond Camden added

CapFirst

April 25, 2016

Chris Wigginton added

loremIpsum

January 18, 2016

Gary Stanton added

calculateArrival...

November 19, 2015

Sebastiaan Naafs - van Dijk added

getDaysInQuarter

November 13, 2015