Last active
June 10, 2019 09:50
-
-
Save rootsec1/d132fe60f192cce8001758a856e8dde0 to your computer and use it in GitHub Desktop.
Cloud function for Fibonacci number check via HTTP triggers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
exports.pruoo = functions.https.onRequest((request, response) => { | |
let a:number = 0; | |
let b:number = 1; | |
let n = request.query.n; | |
console.log(request.query); | |
for(let i:number=2; i<=n; i++) { | |
const c:number = a+b; | |
console.log(c); | |
if(n===c || n===b || n===a) response.status(200).json({ "success": "true" }); | |
else if(c>n) response.status(200).json({ "success": "false" }); | |
a=b; | |
b=c; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment