factorial.js 494 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, 25, 1001, 25, 0, 24, 1001, 24, -1, 24, 1006, 24, 20, 2, 25, 24, 25, 1005, 24, 6, 4, 25, 99];
  11. const c = new Computer(program, {
  12. inputFromConsole: true,
  13. outputToConsole: true,
  14. });
  15. c.Run();