Results 1 to 4 of 4

Thread: Factorial

  1. #1
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Factorial

    [src]
    // Application using a recursively defined method

    public class Factorial
    {
    static final long MAX = 10;

    public static void main (String[] args)
    {
    for ( long i = 0; i <= MAX; i++)
    System.out.println(i + "! = " + factorial(i));
    }

    static private long factorial(long number)
    {
    if (number <= 1)
    return 1; //base case
    else
    return number * factorial(number - 1);
    }

    }



    [/src]

  2. #2
    Zephyrus
    Guest


    Re: Factorial

    ขอเสริมนิดหนึ่งนะครับถ้าเป็น 100 factorial ก็ให้ใช่ BigInteger

    [code]import java.math.BigInteger;

    public class Factorial {


  3. #3
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: Factorial

    ขอบคุณ Zephyrus ที่เสริมให้ครับ
    ไม่ทราบว่าคุณ Zephyrus ต้องการ upgrade สถานะเป็น special member ไหม
    คือ สามารถ login เข้าใช้ server เราได้ พื้นที่ 50 MB
    support: Mysql, php, perl, html
    ถ้าสนใจเชิญทำตามขั้นตอนตามนี้เลยนะครับ http://seri.kmutt.ac.th/cs02/citec/forum2/...hp?TopicID=1727
    เรายินดีสนับสนุนคนที่เผยแพร่ความรู้ครับ

  4. #4
    Zephyrus
    Guest


    Re: Factorial

    ขอบคุณมากๆครับ.. แต่ผมยังไม่ใช้อะไรครับถ้าคำถามไหนผมพอจะตอบได้ก็ช่วยๆกันตอบครับ :-) ขอบคุณ Webmaster ที่ให้เกียรติผมครับ

Similar Threads

  1. Replies: 13
    Last Post: 04-01-2010, 10:04 AM
  2. Replies: 9
    Last Post: 16-08-2007, 06:41 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •