summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test100_recursivefunctions/scilabcode/RecursivePower.sci
blob: 87430bba048eaf20a31c3093725ce525880f1d46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//SCI2C: NIN=          2
//SCI2C: NOUT=         1
//SCI2C: OUT(1).TP=    IN(1).TP
//SCI2C: OUT(1).SZ(1)= FA_SZ_1(IN(1).SZ)
//SCI2C: OUT(1).SZ(2)= FA_SZ_2(IN(1).SZ)
//SCI2C: DEFAULT_PRECISION= FLOAT

function outrec = RecursivePower(in,pwrfct)


if (pwrfct == 0)
   outrec = ones(in);
end

if (pwrfct == 1)
   outrec = in;
end

if (pwrfct > 1)
   outrec = in .* RecursivePower(in,pwrfct-1);
end

endfunction