Computer Science, Mathematics, Learning, Learning To Code, Code.
13, 21… The 0th and the 1st terms are 0 and 1 respectively, so we can just return the value of the term itself! That is what is happening with if(n ≤ 1) return n: If we are at either the 0th or 1st term, return 0 or 1 respectively. Intuitively speaking, fibonacci sequence terms can not be negative.