VB.NET
Function someFunc(ByVal n)
If n < 2 Then Return n Else Return someFunc(n - 1) + fib(n - 2)
End Function
Imports System.Console
Module Fibonacci
myFib
Sub Main()
Dim n As Integer
For n = 1 To 30
WriteLine(n & ":" & someFunc(n))
Next
End Sub
End Module
JAVA
public static int someFunc(int n) {
if (n < 2) {
return n;
}
else {
return fib(n-1)+fib(n-2);
}
}
public static void main(String[] args) {
for (int i=0; i<=46; i++)
System.out.print(someFunc(i)+", ");
}
Javascript
function someFunc(n) {
return n<2?n:fib(n-1)+fib(n-2);
}
for(i=0; i<=20; i++) document.write("fib(" + i + ") = " + fib(i) + "");
Function someFunc(ByVal n)
If n < 2 Then Return n Else Return someFunc(n - 1) + fib(n - 2)
End Function
Imports System.Console
Module Fibonacci
myFib
Sub Main()
Dim n As Integer
For n = 1 To 30
WriteLine(n & ":" & someFunc(n))
Next
End Sub
End Module
JAVA
public static int someFunc(int n) {
if (n < 2) {
return n;
}
else {
return fib(n-1)+fib(n-2);
}
}
public static void main(String[] args) {
for (int i=0; i<=46; i++)
System.out.print(someFunc(i)+", ");
}
Javascript
function someFunc(n) {
return n<2?n:fib(n-1)+fib(n-2);
}
for(i=0; i<=20; i++) document.write("fib(" + i + ") = " + fib(i) + "");
No comments:
Post a Comment