3 ms·
I think you would really enjoy learning some other languages. You obviously understand programming concepts really well... but, node.js for this? really? Even
by deckiedan 13y ago
I think you would really enjoy learning some other languages. You obviously understand programming concepts really well... but, node.js for this? really? Even C is less verbose than that JS...:
#include <stdio.h>
int main(void){
unsigned int lineno=0;
char line[1000];
unsigned int number;
while (fgets(line, 999, stdin)) {
sscanf(line, "%u", &number);
printf("%u\n", number * lineno++);
}
return(0);
}
which reads stdin, and writes to stdout.
I'm sure the C may not be perfect, I've not really used it in years. Node for a task like this is a bit like using a Nimitz Class Aircraft Carrier to hammer in a nail...
- tracker1 13y agostdin/out for node.js var i=0 ,stream = require("stream") ,rl = require('readline').createInterface({ input: process.stdin ,output: new stream.Writable() }); rl.on('line',function(line){ process.stdout.write(((+line || 0) * ++i) + '\n'); }); process.stdin.resume(); I actually know several languages... ;-) Just find that node is my go to tool these days.