const fib = (num) => {
if (num == 0) return 0
let x = 'I', y = ''
for (let i = 0; i < num; i++) {
if (i % 2 == 0)
x += y
else
y += x
return Math.max(x.length, y.length);
}
}
Golly that was hard to do on mobile!
No need for maths or recursion here, let's use base 0 with a loop!
Golly that was hard to do on mobile!
No need for maths or recursion here, let's use base 0 with a loop!
Which language is this? I suspect Java, but I'm not sure at a glance.
This reminds me a bit of my alternating pair approach (in C), but it's strangely lovely. Nice work.
P.S. Did you mean for
y += X
to have an upper caseX
?Thank you! It's JavaScript, easiest thing for me on my phone. And I did not, thank you! I'll change it now.
I figure it could probably be made much fancier, but I'm not up for it right now!
Shoot, bonus points for typing it on mobile at all, mate. ;-)