This is a simple program, compiled with the Mono C# compiler, no optimisation.

Here is the original C# source code:

using System;

class Fibo {
    private static int fib (int x) {
        if (x > 1)
            return (fib(x - 1) + fib(x - 2));
        else return (x);
    }

    public static int Main( String[] args) {
    int number = 0, value;

        try {
            number = Convert.ToInt32(args[0]);  
        } catch (Exception e) {
            Console.WriteLine ("Input error");
            return 1;
        }
        value = fib(number);
        Console.WriteLine ("fibonacci({0}) = {1}", number, value);
        return 0;
    }
}

You use the program like this:

% mono Fibo 10
fibonacci(10) = 55
% mono Fibo abc
Input error
%

The corresponding Java source code (for bytecode decompiler tests) is in DecompilerFiboTestSource.

-- MikeVanEmmerik - 06 Mar 2003
CategoryDecompilation

Revision: r1.2 - 11 Mar 2003 - 02:47 - MikeVanEmmerik
Transform > DecompilationDotNetTests? > DecompilerFiboDotNetSource
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback