Skip to content

Instantly share code, notes, and snippets.

@mehtaparitosh
Created August 20, 2017 10:12
Show Gist options
  • Save mehtaparitosh/aff63d153295bb8900a021f07b1a8277 to your computer and use it in GitHub Desktop.
Save mehtaparitosh/aff63d153295bb8900a021f07b1a8277 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.math.*;
class battel
{
int findValue(int x){
BigInteger f = new BigInteger;
f = 1;
for(int i=1;i<=x;i++){
f=f*i;
}
int count = 0;
int sum = 0;
while(f>0){
if(f%10 == 0) {
count++;
}
else {
sum += f%10;
}
f = f/10;
}
return (sum - count);
}
public static void main (args[]){
int n, i;
Scanner n=new Scanner(System.in);
int total =n.nextInt();
int[] lucky = new int[total];
for(i=0; i<total; i++){
lucky[i] = n.nextInt();
}
for(i=0; i<lucky.length; i++){
findValue(lucky[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment