2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 22:38:04 +02:00
LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10

22 lines
503 B
Text
Raw Normal View History

2014-03-28 11:06:02 +01:00
// file Fibonacci.x10
public class Fibonacci {
public static def fib(n:Int) {
if (n < 2) {
return n;
}
val f1:Int;
val f2:Int;
f1 = fib(n-1);
f2 = fib(n-2);
return f1 + f2;
}
public static def main(args:Rail[String]) {
x10.io.Console.OUT.println("This is fibonacci in X10.");
for (var i:Int=0; i < 10; ++i) {
x10.io.Console.OUT.println(i + ": " + fib(i));
fib(i);
}
}
}