Problem1194--Java 计算阶乘

1194: Java 计算阶乘

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 2  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

代码如下:

import java.awt.*;
import javax.swing.*;
//*********Found********** 
public class Java_3 extends _____________________ {
 
    JTextArea outputArea;
 
    public void init() {
        outputArea = new JTextArea();
        //*********Found********** 
        Container c = ____________________();  // Get Content Pane
        //*********Found********** 
        c.add(__________________);
        //计算0至10的阶乘 
        for (long i = 0; i <= 10; i++) {
            outputArea.append(
                    i + "! = " + factorial(i) + "\n");
        }
    }
    //阶乘的递归定义 
    public long factorial(long number) {
        if (number <= 1) {
            return 1;
        } else {
            return number * factorial(number - 1);
        }
    }
}

Source/Category