@@ -5,16 +5,16 @@ Debug = true
55[33m[stage-9] [test-1] [0m[94mWriting contents to ./test.lox:[0m
66[33m[stage-9] [test-1] [0m[33m[test.lox][0m print clock() + 23;
77[33m[stage-9] [test-1] [0m[94m$ ./your_program.sh run test.lox[0m
8- [33m[your_program] [0m1.731520075985E9
9- [33m[stage-9] [test-1] [0m[92m✓ 1731520075.985000 [0m
8+ [33m[your_program] [0m1.731566502731E9
9+ [33m[stage-9] [test-1] [0m[92m✓ 1731566502.731000 [0m
1010[33m[stage-9] [test-1] [0m[92m✓ 1 line(s) match on stdout[0m
1111[33m[stage-9] [test-1] [0m[92m✓ Received exit code 0.[0m
1212[33m[stage-9] [test-2] [0m[94mRunning test case: 2[0m
1313[33m[stage-9] [test-2] [0m[94mWriting contents to ./test.lox:[0m
1414[33m[stage-9] [test-2] [0m[33m[test.lox][0m print clock() / 1000;
1515[33m[stage-9] [test-2] [0m[94m$ ./your_program.sh run test.lox[0m
16- [33m[your_program] [0m1731520.053144
17- [33m[stage-9] [test-2] [0m[92m✓ 1731520.053144 [0m
16+ [33m[your_program] [0m1731566.4798410002
17+ [33m[stage-9] [test-2] [0m[92m✓ 1731566.479841 [0m
1818[33m[stage-9] [test-2] [0m[92m✓ 1 line(s) match on stdout[0m
1919[33m[stage-9] [test-2] [0m[92m✓ Received exit code 0.[0m
2020[33m[stage-9] [test-3] [0m[94mRunning test case: 3[0m
@@ -83,24 +83,23 @@ Debug = true
8383[33m[stage-8] [test-3] [0m[92m✓ Received exit code 0.[0m
8484[33m[stage-8] [test-4] [0m[94mRunning test case: 4[0m
8585[33m[stage-8] [test-4] [0m[94mWriting contents to ./test.lox:[0m
86- [33m[stage-8] [test-4] [0m[33m[test.lox][0m // This program demonstrates the use of recursive functions to determine if a number is even or odd.
87- [33m[stage-8] [test-4] [0m[33m[test.lox][0m // This is a classic example of mutual recursion.
88- [33m[stage-8] [test-4] [0m[33m[test.lox][0m fun isEven(n) {
89- [33m[stage-8] [test-4] [0m[33m[test.lox][0m if (n == 0) return true;
90- [33m[stage-8] [test-4] [0m[33m[test.lox][0m return isOdd(n - 1);
86+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m // This program calculates the cumulative sum of numbers from 1 to n.
87+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m fun cumulative_sum() {
88+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m var n = 10; // Fixed value
89+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m var total = 0;
90+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m var i = 1;
91+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m while (i <= n) {
92+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m total = total + i;
93+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m i = i + 1;
94+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m }
95+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m print "The cumulative sum from 1 to 10 is: ";
96+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m print total;
9197[33m[stage-8] [test-4] [0m[33m[test.lox][0m }
9298[33m[stage-8] [test-4] [0m[33m[test.lox][0m
93- [33m[stage-8] [test-4] [0m[33m[test.lox][0m fun isOdd(n) {
94- [33m[stage-8] [test-4] [0m[33m[test.lox][0m if (n == 0) return false;
95- [33m[stage-8] [test-4] [0m[33m[test.lox][0m return isEven(n - 1);
96- [33m[stage-8] [test-4] [0m[33m[test.lox][0m }
97- [33m[stage-8] [test-4] [0m[33m[test.lox][0m
98- [33m[stage-8] [test-4] [0m[33m[test.lox][0m print isEven(19);
99- [33m[stage-8] [test-4] [0m[33m[test.lox][0m print isOdd(43);
100- [33m[stage-8] [test-4] [0m[33m[test.lox][0m
99+ [33m[stage-8] [test-4] [0m[33m[test.lox][0m cumulative_sum();
101100[33m[stage-8] [test-4] [0m[94m$ ./your_program.sh run test.lox[0m
102- [33m[your_program] [0mfalse
103- [33m[your_program] [0mtrue
101+ [33m[your_program] [0mThe cumulative sum from 1 to 10 is:
102+ [33m[your_program] [0m55
104103[33m[stage-8] [test-4] [0m[92m✓ 2 line(s) match on stdout[0m
105104[33m[stage-8] [test-4] [0m[92m✓ Received exit code 0.[0m
106105[33m[stage-8] [0m[92mTest passed.[0m
0 commit comments