import java.io.*;
public class test {

    public static void main(String args[])throws IOException {
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("請輸入費氏數列項數m:");
        int m=Integer.parseInt(buf.readLine());
        System.out.println("費氏數列第"+m+"項數的值為"+fib(m));
    }
    
    public static long fib(int n){
        if(n==1)
                return 1;
        else if (n==2)
                return 1;
        else
                return fib(n-1)+fib(n-2); 
    }   
}

--------------------Configuration: --------------------
請輸入費氏數列項數n:46
費氏數列第46項數的值為1836311903

浮雲 發表在 痞客邦 留言(5) 人氣()

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim num(999999) As Integer
        num(0) = 1
        num(1) = 1
        For i As Integer = 2 To 999999
            num(i) = num(i - 2) + num(i - 1)
            If num(i) >= 1836311903 Then Exit For
        Next
        For i As Integer = 0 To 999999
            If num(i) = 0 Then
                Exit For
            Else
                Response.Write("num(" & i & ")=" & num(i) & " ")
            End If
        Next
    End Sub
End Class

浮雲 發表在 痞客邦 留言(0) 人氣()

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

浮雲 發表在 痞客邦 留言(0) 人氣()

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

浮雲 發表在 痞客邦 留言(0) 人氣()

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

浮雲 發表在 痞客邦 留言(0) 人氣()

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

浮雲 發表在 痞客邦 留言(0) 人氣()

在職訓中心的第二階段開始了。

由於同學的陷害,

浮雲 發表在 痞客邦 留言(4) 人氣()

原本應該快樂的假期,
為何變得如此地悲傷?
是誰?

浮雲 發表在 痞客邦 留言(0) 人氣()

  • Oct 26 Fri 2007 00:04
  • 轉移

這次的我沒有喝酒,
我說過不再為同一個人而喝醉!
剛好又在階段假,

浮雲 發表在 痞客邦 留言(2) 人氣()

  • Oct 23 Tue 2007 00:44
  • 有感

生活是快樂的,
卻又點苦悶、有點無奈!
苦悶的是~~

浮雲 發表在 痞客邦 留言(4) 人氣()