Given u0 = 1, u1 = 2 and the relation 6unun+1-5unun+2+un+1un+2 = 0 calculate un for any integer n >= 0.
Examples:
Call fcn
the function such as fcn(n) = un.
fcn(17) -> 131072; fcn(21) -> 2097152
Remark:
You can take two points of view to do this kata:
the first one purely algorithmic from the definition of un
the second one - not at all mandatory, but as a complement - is to get a bit your head around and find which sequence is hidden behind un.
(요약) 2
의 n
제곱을 return
.
function fcn (n) { return Math.pow(2, n); }
주어진 방정식에
1, 2
번 째 값을 대입해보니4
가 나옴.
혹시나 싶어서 한 번 더 해보니8
이 나옴.
2
의n
제곱을 구하는 거겠구나 싶어서 바로 함.