Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Solve(arr) {
- var start = arr[0];
- var end = arr[1];
- function isFib(val) {
- var prev = 0;
- var curr = 1;
- while (prev <= val) {
- if (prev === val) {
- return true;
- }
- curr = prev + curr;
- prev = curr - prev;
- }
- }
- var result = "<table>\n<tr><th>Num</th><th>Square</th><th>Fib</th></tr>\n";
- for (var i = start; i <= end; i++) {
- if (isFib(i) === true) {
- result += "<tr><td>" + i + "</td><td>" + Math.pow(i, 2) + "</td><td>" + "yes" + "</td></tr>\n";
- } else {
- result += "<tr><td>" + i + "</td><td>" + Math.pow(i, 2) + "</td><td>" + "no" + "</td></tr>\n";
- }
- }
- result += "</table>";
- //console.log(result);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement