fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. function range(x, y, z) {
  5. var a = [];
  6. if (z == undefined) {
  7. z = 1
  8. }
  9. if (z < 0) {
  10. for (var i = y;i>=x;i +=z) {
  11. a.push(i)
  12. }
  13. } else {
  14. for (var i = 0; x + i <= y; i += z) {
  15. a.push(x + i);
  16. }
  17. }
  18. return a;
  19. }
  20.  
  21. function sum(a) {
  22. var s = 0;
  23. for (var i = 0; i < a.length; i++) {
  24. s += a[i];
  25. }
  26. return s;
  27. }
  28.  
  29. console.log(range(1, 100, -5))
Success #stdin #stdout 0.14s 52112KB
stdin
Standard input is empty
stdout
[ 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5 ]