Number of Hundreds
Programming Basics · JavaScript
TASK
Problem
Given non-negative integer `n`, print complete hundreds.
EXAMPLE
Example
9876
98
LIMITS
Constraints
All numeric input values fit in JavaScript `Number`.
LEARN
Theory for this problem
+
### Number of Hundreds
Integer division separates higher decimal/time units, while `%` returns the remainder. These two operations let a program isolate digits or split a total number of seconds/minutes into components.
NEED HELP?
Hints
+
['Decide which part comes from division and which part comes from the remainder.', 'Do not mix the loop counter with the accumulated answer; those variables serve different roles.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let n = Number(input);
let result = Math.floor((n) / (100));
console.log(result);