answersLogoWhite

0

Find factorial of a num N?

Updated: 10/12/2022
User Avatar

Wiki User

14y ago

Best Answer

function fact(int n); ans = n * fact(n-1); endfunction

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find factorial of a num N?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a program in c to calculate factorial of number?

First of all we will define what factorial is and how to it is calculated.Factional is non negative integer. Notation would be n! It is calculated by multiplying all integers from 1 to n;For example:5! = 1 x 2 x 3 x 4 x 5 = 120.Note: 0! = 1Small C program that illustrates how factorial might be counted:#include int factorial(int num);int main() {int num;printf("Enter number: ");scanf("%d", &num);printf("Factorial: %d\n", factorial(num));return 0;}int factorial(int num) {if (num == 0) {return 1;}return num * factorial(num - 1);}Testing:Enter number: 5Factorial: 120Enter number: 0Factorial: 1


How many numbers of n digits exist if the sum of all digits is s?

The number of n-digit numbers where the sum of the digits is s can be calculated using stars and bars method. It can be obtained by arranging (s - 1) + n stars and inserting n - 1 bars among them, which gives a total of (n + s - 1) choose (n - 1) possible numbers.


How do you write a full program to find factors of given number in UNIX shell programming?

echo "Enter a number: " read num i=2 res=1 if [ $num -ge 2 ] then while [ $i -le $num ] do res=`expr $res \* $i` i=`expr $i + 1` done fi echo "Factorial of $num = $res" v


Factorial in c program using for loop?

#include<stdio.h> #include<conio.h> void main() { int i,n,fact=1; clrscr(); printf("enter the number"); scanf("%d",&n); for(i=1;i<=n;i++) printf("%d",n); fact=fact*i; { printf("the factorial is=%d",fact); } getch(); } By:-Abhishek Goyal(goyal.abhi40@yahoo.com)


What is a factorial function in Visual Basic?

' Iterative solution Function iterativeFactorial(ByVal n As Long) As Long Dim factorial As Long = 1 For i As Long = 1 To n factorial *= i Next Return factorial End Function ' Recursive solution Function recursiveFactorial(ByVal n As Long) As Long If n <= 1 Then Return n End If Return n * recursiveFactorial(n - 1) End Function


Write a program in C to find the factoial of 5?

/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */ #include <stdio.h> int main ( ) { int n = 5 , factorial = 1 ; while ( n != 0 ) { factorial *= n ; n -- ; } printf ( "%i\n" , factorial ) ; return 0; }


Write a C-like program fragment that calculate the factorial function for argment 12 with do while loop?

#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }


Mini project in c language with coding?

C Program to find factorial of a numberSimple C Programint main() {int n,i,f=1;printf("enter any num \n");scanf("%d",&n);for(i=1;i


Abap Program To find Factorial of number?

report zbharath. data:num type i value 5, fac type i value 0. perform fact using num changing fac. write:/ 'factorial of',num,'is',fac. form fact. using value(f-num) type i. changing f-fact type i. f-fact=1. while f-num ge 1. f-fact=f-fact*f-num. f-num=f-num-1. endwhile. endform.


How do you wrte ac programe for factorial?

#include <stdio.h> int main() { int fact=1,num; printf("Enter number: "); scanf("%d",&num); if((num==0) (num==1)) { printf("Factorial = %d",fact); return 0; } else { while(num!=1) { fact=fact*num; num--; } printf("Factorial = %d",fact); return 0; } }


C program to find factorial of a no?

this is a code for calculating it recursivelly: float Factorial (float n) { if (n<=1) return 1.0; else return n* Factorial(n-1); }


How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n! int fact(final int n) { // keep track of factorial calculation in f // f starts at n, and we will multiply it by all integers less than n int f = n; // loop from n-1 down to 2 for(int i = (n - 1); i > 1; --i) { // increase our total product f *= i; } return f; }