Circumference
Programming Basics · JavaScript
TASK
Problem
Given radius `r`, use π = 3.14 and print circumference `2πr`.
EXAMPLE
Example
5
31.400000000000002
LIMITS
Constraints
All numeric input values fit in JavaScript `Number`.
LEARN
Theory for this problem
+
### Circumference
JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.
NEED HELP?
Hints
+
['Write the formula using named intermediate values if it contains more than one operation.', 'Before printing, output only the computed result and do not add explanatory text that is absent from the required format.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let r = Number(input);
let result = (((2) * (3.14)) * (r));
console.log(Object.is(result, 0) ? '0.0' : result);