~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to tads/tads3/test/data/fib.t

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <tads.h>
 
2
 
 
3
main(args)
 
4
{
 
5
    local t0 = getTime(GetTimeTicks);
 
6
    local n = (args.length() >= 2 ? toInteger(args[2]) : 10);
 
7
    
 
8
    "fib(<<n>>) = <<fib(n)>>\n";
 
9
    "elapsed time = <<getTime(GetTimeTicks) - t0>> ms\n";
 
10
}
 
11
 
 
12
fib(n)
 
13
{
 
14
    if (n <= 2)
 
15
        return 1;
 
16
    else
 
17
        return fib(n-2) + fib(n-1);
 
18
}
 
19