I am looking to create a unique variation of the Fibonacci sequence. The implementation I have in mind is as follows:
(FSM) - FSM(0) = 0,
FSM(1) = 1,
FSM(n) = FSM(n - 2) + FSM(n - 1) / n
How can this be achieved using JavaScript? Specifically, I need to input a large integer 60000000
and generate the next 10 numbers in the sequence.
It is important to note that there is a division by 'n' in the equation involving (n-1).
Below is my current code snippet:
var fibonacci = (function() {
var memo = {};
function f(n) {
var value;
if (n in memo) {
value = memo[n];
} else {
if (n === 0 || n === 1)
value = n;
else
value = f(n - 1)/n + f(n - 2);
memo[n] = value;
}
console.log(value);
return value;
}
return f;
})();
fibonacci(10);
My task now requires me to "Calculate the 10 modified Fibonacci Numbers following the 60000000th element."
However, attempting to call fibonacci(60000000); will result in a crash.