Aggiorna index.js
This commit is contained in:
parent
c908bf786a
commit
728bbdcf38
1 changed files with 21 additions and 0 deletions
21
index.js
21
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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue