From 71bbc1e65d7bbc4bf4ba2bc27e435c91e7d207fb Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sat, 7 Dec 2024 20:02:32 +0000 Subject: [PATCH] Make an example program a bit more interesting --- README.md | 2 +- example/example.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 67c5625..7751ac4 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ As a result, you'll get an `example.raw` binary. To execute it: ./rve ../example/example.raw ``` -The expected output of the example program is `269`. +The expected output of the example program is `40320`. diff --git a/example/example.c b/example/example.c index 483913d..7830293 100644 --- a/example/example.c +++ b/example/example.c @@ -1,9 +1,14 @@ -static int mem = 56; +static int mem = 1; + +int fact(int n) { + if (n == 0) + return 1; + + return n * fact(n-1); +} int main() { - int a = 42; - int b = 5; - mem = mem + a*b + 3; + mem = fact(8); return 0; }