Skip to content

Commit

Permalink
fix: update to correct fibonacci example program (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: John Guibas <[email protected]>
  • Loading branch information
jtguibas and John Guibas authored Feb 14, 2024
1 parent 54b64b6 commit e8e6c0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Binary file modified examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
24 changes: 14 additions & 10 deletions examples/fibonacci/program/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#![no_main]
sp1_zkvm::entrypoint!(main);

pub fn main() {
let n = 50000;
let mut a = 0;
let mut b = 1;
let mut sum;
for _ in 1..n {
sum = a + b;
a = b;
b = sum;
use std::hint::black_box;

fn fibonacci(n: u32) -> u32 {
let mut nums = vec![1, 1];
for _ in 0..n {
let mut c = nums[nums.len() - 1] + nums[nums.len() - 2];
c %= 7919;
nums.push(c);
}
println!("b: {}", b);
nums[nums.len() - 1]
}

pub fn main() {
let result = black_box(fibonacci(black_box(50000)));
println!("result: {}", result);
}

0 comments on commit e8e6c0a

Please sign in to comment.