Scientific Calculator
SasanM/isFibonacci
By sasan
test if the argument is a fibonacci number
is_fib=function(fi){
var a=0;
var b=1;
var c=0;
var i=2;
while (i < fi) -> (
c=a+b;
a=b;
b=c;
if (c==fi) -> i=fi;
i +=1;
);
i -=1;
if (i == fi) -> "true" else "false";
}
0 Comments
Sign in to leave a comment