Async Double
JavaScript
Easy
4 views
Problem Description
Given a number x, return 2*x using async/await style. Print the result.
Input Format
One integer x.
Output Format
One integer.
Constraints
x is integer in -1e9..1e9.
Official Solution
const fs=require('fs');const s=fs.readFileSync(0,'utf8').trim();if(!s)process.exit(0);const x=BigInt(s);const twice=async v=>{await Promise.resolve();return v*2n;};(async()=>{const ans=await twice(x);process.stdout.write(ans.toString());})();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!