Public
Versions
- Open: Version+39-0export async function val_PJEj4CadkM(req) {try {// Execute the code directly and capture its resultconst result = await (async () => {const calculatePi = (iterations) => {let pi = 0;let divisor = 1;for (let i = 0; i < iterations; i++) {pi += (i % 2 === 0 ? 1 : -1) / divisor;divisor += 2;}return pi * 4;};return calculatePi(1000000);})();// Return the result in a properly formatted responsereturn new Response(JSON.stringify({result: result,type: typeof result}), {headers: { 'Content-Type': 'application/json' }});} catch (error) {return new Response(JSON.stringify({error: {message: error.message,stack: error.stack,type: error.name}}), {status: 500,headers: { 'Content-Type': 'application/json' }});
dhvanil-val_pjej4cadkm.web.val.run
Updated: November 9, 2024