Problem 40. tableof5.js ( coding test)
/*Question Iterate Given a positive integer n, print the first n natural numbers which are divisible by n. Input Format: One line containing a positive integer, denoting n. Output Format: n lines containing one integer each. Example: Input: 5 Output: 5 10 15 20 25 Explanation: 5, 10, 15, 20, 25 are the first 5 natural numbers divisible by 5. */ let fs = require ( "fs" ); let data = fs . readFileSync ( 0 , 'utf-8' ); let idx = 0 ; data = data. split ( ' \n ' ); function readLine () { idx ++ ; return data[idx - 1 ]. trim (); } //====================================================================================================== let num = parseInt ( readLine ()); //5 for ( let i = 1 ; i <= num; i ++ ) { console. log (num * i); } TERMINAL: Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$ node tableof5.js <input.txt 5 10 15 20 25 Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$