self
Programming and Technical
Programming
Program
WAP to calculate x = (b-1)! - (b-2)!....-(b-a)!
Read Solution (Total 3)
-
- import java.util.Scanner;
class Factorial
{
public static void main(String args[])
{
int a, c, fact = 1;
System.out.println("Enter an integer to calculate it's factorial");
Scanner in = new Scanner(System.in);
a = in.nextInt();
if ( a < 0 )
System.out.println("Number should be non-negative.");
else
{
for ( c = 1 ; c - 10 years agoHelpfull: Yes(2) No(1)
- int main()
{ int i,num,fact;
scanf("%d",&num);
fact=1;
if(num==0)
{ fact=1; }
else {
for(i=1;i - 10 years agoHelpfull: Yes(1) No(0)
- class sFact
{ void fact(int b)
{ int f=1,i,j,y=0 ;
for(j=b-1;j>=1;j--)
{
f = 1;
for(i=j;i>=1;i--)
{
f = f*i;
}
y = y-f ;
if (y - 10 years agoHelpfull: Yes(0) No(0)
self Other Question