8. วัตถุสิ่งของ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 8-18  ตัวอย่างการใช้งานคลาส BigInteger
import java.math.BigInteger;
public class TestBigInteger {
  public static void main(String[] args) {
    int n = 100;
    System.out.println(n + "! = " + fac(n));
  }
  public static BigInteger fac(int n) {
    BigInteger nfac = new BigInteger("1");
    for (int i=1; i<=n; i++) {
      nfac = nfac.multiply(new BigInteger("" + i));
    }
    return nfac;   
  }
}
©2009 S.Prasitjutrakul