factorial.js 538 B

123456789101112131415161718
  1. /**
  2. * Calculate the factorial of a given number
  3. *
  4. * Calculates the factorial of a number, outputting the final result.
  5. *
  6. * Added to the Intcode wiki by myself
  7. * @see https://esolangs.org/wiki/Intcode#Example_Programs
  8. */
  9. const Computer = require("../IntComp/Computer");
  10. const program = [3, 34, 1007, 34, 1, 35, 1005, 35, 30, 1001, 34, 0, 33, 1001, 33, -1, 33, 1006, 33, 27, 2, 34, 33, 34, 1005, 33, 13, 4, 34, 99, 104, 1, 99];
  11. const c = new Computer(program, {
  12. inputFromConsole: true,
  13. outputToConsole: true,
  14. });
  15. c.Run();