Pages

Sunday, December 26, 2010

Fibonaci Series

/**
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 26, 2010
 * @version : 1.0
 */

/**
 * This function provide fibonaci series
 * @param n number how many term expected
 * @return data an array of the series
 */
function fibo(n){
    var data = new Array();
    data[0]=1;
    data[1]=1;
    for(i=2;i<n;i++){
        data[i] = data[i-1]+data[i-2];
    }
    return data;
}

No comments:

Post a Comment