First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Wednesday, July 16, 2014

500!

Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-623
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=564

Code:

import java.math.BigInteger;
import java.util.*;
public class Uva_623 {

public static void main(String[] args) {
Scanner in=new Scanner(System.in);
BigInteger a,b,c;
while(in.hasNext()){
       a=in.nextBigInteger();
       c=BigInteger.ONE;
       for(b=BigInteger.ONE;b.compareTo(a)<=0;b=b.add(BigInteger.ONE)){
        c=c.multiply(b);  
}
     System.out.println(a +"!"+ "\n"+ c);
}
}
}

No comments:

Post a Comment