File: fib.sip

package info (click to toggle)
sip5 5.5.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,380 kB
  • sloc: ansic: 37,043; yacc: 6,670; python: 2,107; lex: 823; makefile: 18; cpp: 4
file content (24 lines) | stat: -rw-r--r-- 368 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Define the SIP wrapper to the (theoretical) fib library.

%Module(name=fib, language="C")

int fib_n(int n);
%MethodCode
    if (a0 <= 0)
    {
        sipRes = 0;
    }
    else
    {
        int a = 0, b = 1, c, i;

        for (i = 2; i <= a0; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }

        sipRes = b;
    }
%End