/***
Bismillahir Rahmanir Rahim
Read the name of Allah, who created you!!!
Author : Shah Newaj Rabbi Shishir
Department of CSE, City University, Bangladesh.
***/
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner (System.in);
int n,temp,i,l;
String str;
char []Char = new char[1];
while (in.hasNext())
{
n = in.nextInt();
System.out.printf("%5d -> ",n);
BigInteger fact = BigInteger.valueOf(1);
for (i=1; i<=n; i++)
fact = fact.multiply(BigInteger.valueOf(i));
str = fact.toString();
Char = str.toCharArray();
l = Char.length-1;
int sum = 0;
for (i=l; i>=0; i--)
{
if (Char[i] != '0')
{
System.out.println(Char[i]);
break;
}
}
}
}
}
Bismillahir Rahmanir Rahim
Read the name of Allah, who created you!!!
Author : Shah Newaj Rabbi Shishir
Department of CSE, City University, Bangladesh.
***/
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner (System.in);
int n,temp,i,l;
String str;
char []Char = new char[1];
while (in.hasNext())
{
n = in.nextInt();
System.out.printf("%5d -> ",n);
BigInteger fact = BigInteger.valueOf(1);
for (i=1; i<=n; i++)
fact = fact.multiply(BigInteger.valueOf(i));
str = fact.toString();
Char = str.toCharArray();
l = Char.length-1;
int sum = 0;
for (i=l; i>=0; i--)
{
if (Char[i] != '0')
{
System.out.println(Char[i]);
break;
}
}
}
}
}
No comments:
Post a Comment