2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 22:38:04 +02:00
This commit is contained in:
Martin Thoma 2014-03-28 11:51:59 +01:00
parent 860e3c066b
commit d5ad212703
6 changed files with 67 additions and 4 deletions

View file

@ -1,14 +1,16 @@
// file Fibonacci.x10
public class Fibonacci {
public static def fib(n:Int) {
public static def fib(n:Int): Int {
if (n < 2) {
return n;
}
val f1:Int;
val f2:Int;
f1 = fib(n-1);
f2 = fib(n-2);
finish {
async f1 = fib(n-1);
async f2 = fib(n-2);
}
return f1 + f2;
}
@ -16,7 +18,6 @@ public class Fibonacci {
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);
}
}
}