Mercurial > octave-nkf
annotate test/test_recursion.m @ 5915:b2e1be30c8e9 ss-2-9-7
[project @ 2006-07-28 18:08:56 by jwe]
author | jwe |
---|---|
date | Fri, 28 Jul 2006 18:08:56 +0000 |
parents | 1ad66ea35fe5 |
children | 93c65f2a5668 |
rev | line source |
---|---|
5590 | 1 %% Automatically generated from DejaGNU files |
2 | |
3 %% test/octave.test/recursion/recursion-1.m | |
4 %!function y = f (x) | |
5 %! if (x == 1) | |
6 %! y = x; | |
7 %! return; | |
8 %! else | |
9 %! y = x * f (x-1); | |
10 %! endif | |
11 %!test | |
12 %! assert(f (5),120); | |
13 | |
14 %% test/octave.test/recursion/recursion-2.m | |
15 %!function y = f (x) | |
16 %! if (x == 1) | |
17 %! y = x; | |
18 %! return; | |
19 %! else | |
20 %! y = f (x-1) * x; | |
21 %! endif | |
22 %!test | |
23 %! assert(f (5),120); | |
24 |