From 728bbdcf386f46f8667515a241b0be48d60375c3 Mon Sep 17 00:00:00 2001 From: PanSi21 Date: Sun, 5 Jan 2025 00:16:45 +0100 Subject: [PATCH] Aggiorna index.js --- index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/index.js b/index.js index c423e11..42c15a3 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,27 @@ import { cc } from "bun:ffi"; import source from "./test.c" with { type: "file" }; + +function fibonacci_js() { + const n = 500000; + let a = 0n; + let b = 1n; + let c; + + for (let i = 2; i <= n; i++) { + c = a + b; + a = b; + b = c; + } + + return b; +} + +const result_js = fibonacci_js(); +console.log("Fibonacci(500000) =", result_js.toString()); + + + const { symbols: { fibonacci }, } = cc({