1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/local/bin/node // // See ../README.md // // // Run as: node ch-2.js < input-file // let SQRT5 = Math . sqrt (5) let PHI = (1 + SQRT5) / 2 require ('readline') . createInterface ({input: process . stdin}) . on ('line', _ => console . log ( Math . round (Math . pow (PHI, +_ + 1) / SQRT5) ))