https://dascript.org/可以有两种风格:有花括号、没花括号
无括号
def fibR(n)
if (n < 2)
return n
else
return fibR(n - 1) + fibR(n - 2)
def fibI(n)
var last = 0
var cur = 1
for i in range(0, n-1)
let tmp = cur
cur += last
last = tmp
return cur
有括号
def fibR(n) {
if (n < 2) {
return n;
} else {
return fibR(n - 1) + fibR(n - 2);
}
}
def fibI(n) {
var last = 0;
var cur = 1;
for i in range(0, n-1); {
let tmp = cur;
cur += last;
last = tmp;
}
return cur;
}
--
FROM 171.106.20.*