20 new API endpoints
Build and Deploy / build (push) Successful in 30s
Build Release / build (push) Successful in 22s
Build and Deploy / deploy (push) Successful in 26s

This commit is contained in:
2026-06-17 06:24:22 +02:00
parent 19c477aa05
commit 56bd3ea604
22 changed files with 856 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
const express = require('express');
const router = express.Router();
function factorial(n) {
if (n === 0 || n === 1) return 1;
let result = 1;
for (let i = 2; i <= n; i++) result *= i;
return result;
}
router.post('/', (req, res) => {
const n = Math.floor(Number(req.body.input));
if (n < 0 || n > 170) return res.status(400).json({ error: 'n must be between 0 and 170' });
res.json({ ret: factorial(n) });
});
router.get('/:n', (req, res) => {
const n = Math.floor(Number(req.params.n));
if (n < 0 || n > 170) return res.status(400).json({ error: 'n must be between 0 and 170' });
res.json({ ret: factorial(n) });
});
module.exports = router;