Created
August 20, 2017 10:12
-
-
Save mehtaparitosh/aff63d153295bb8900a021f07b1a8277 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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