|
|
back to boardWA #1 , plz give wht I hv done wrng then only I can correct it Posted by Paul 6 Nov 2012 23:32 package practice; import java.util.Scanner; public class Factorial { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner (System.in); System.out.println("enter the no"); int num = sc.nextInt(); String s = sc.next();
int k = s.length(); int fact = 1;
if(num %k ==0){ for(int i = num; i>=k; i = i-k){ fact = fact*i; } } else { for(int i =num; i >0; i = i-k){ fact = fact*i; } }
System.out.println(fact); } } Re: WA #1 , plz give wht I hv done wrng then only I can correct it thank you |
|
|