|
|
вернуться в форум[JAVA] Why is it CRASH ? :( import java.util.*; public class MyFact { int factorial(int n,int k) { int res; if(n==1) return 1; else if((n-1)%k!=0) return 1;
res=factorial(n-k,k)*n; return res;
}
public static void main(String [] args) { int fact=1;
MyFact f=new MyFact();
Scanner in=new Scanner(System.in); int n=in.nextInt();
int k=in.nextInt(); System.out.print(+f.factorial(n,k)); } } Edited by author 05.06.2012 18:20 Re: [JAVA] Why is it CRASH ? :( Read the input data format carefully! An integer number "k" does not follow after integer number n. Input format example: 9 !! You should count number of exclamation marks (!). |
|
|