QA.TechInterviews.com - your tech questions answered
Plz Help Me ............?
how do u write aprogram to display a name with out using semicolon?and also how to write a program to find a factorial of a number' n' where 'n' is input by the user?
thanx Nestor for answering this quest but i understood only little:) actually iam a beginner. i am learning it now ............
and is there any site where i can get any hint regarding finding solution.
public class Factorial {

// return n!
// precondition: n >= 0 and n <= 20
public static long factorial(long n) {
if (n < 0) throw new RuntimeException("Underflow error in factorial");
else if (n > 20) throw new RuntimeException("Overflow error in factorial");
else if (n == 0) return 1;
else return n * factorial(n-1);
}

public static void main(String[] args) {
long N = Long.parseLong(args[0]);
System.out.println(factorial(N));
}

}
i will help u but first u help me
simple

void main()
{
if ( printf("your name") )
{ }
}

// done
public class Factorial {

// return n!
// precondition: n >= 0 and n <= 20
public static long factorial(long n) {
if (n < 0) throw new RuntimeException("Underflow error in factorial");
else if (n > 20) throw new RuntimeException("Overflow error in factorial");
else if (n == 0) return 1;
else return n * factorial(n-1);
}

public static void main(String[] args) {
long N = Long.parseLong(args[0]);
System.out.println(factorial(N));
}

}
ask only question...

don't write story... ok
?
for the latter you have a simple function within the formulae in excel

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.