Factorial series in c





Series of factorial numbers in c


#include<stdio.h>
int main(){
  long f=1;
  int i,num,min,max;

  printf("Enter the minimum range: ");
  scanf("%d",&min);

  printf("Enter the maximum range: ");
  scanf("%d",&max);

  printf("Factorial series in given range: ");
  for(num=min;num<=max;num++){
    f=1;

    for(i=1;i<=num;i++)
      f=f*i;

    printf("%ld ",f);
  }

  return 0;
}

Sample output:
Enter the minimum range: 1
Enter the maximum range: 10
Factorial series in given range: 1 2 6 24 120 720 5040 40320 362880 3628800


Algorithm:

Factorial value

The factorial of a number, denoted as n!, is computed by multiplying all positive integers from 1 to n. For instance, the factorial of 5 is calculated as 1 * 2 * 3 * 4 * 5, resulting in 120. It's important to note that the factorial of zero is defined as 1.


No comments: