answersLogoWhite

0


Best Answer

From the manpage of the bc(1) command:

The following is the definition of the recursive factorial function.

define f (x) {

if (x <= 1) return (1);

return (f(x-1) * x);

}

So you could enter that definition of f(), and then call it, for example f(10)

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

bc. Example for 300! is the following command:

echo 'f=1;for (i=1;i<=300;++i) f*=i; print f,"\n"' | bc

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program to calculate factorial value of given number using BC command in UNIX?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to find n th fabonacci number?

#include #include using std::cin;using std::cout;using std::endl;using std::tolower;long factorial(const int& N);int main(){int N = 0; //factorial of Nchar command = 'n';do{cout > N;cout


Program in c to generate table of factorials?

#include #include using std::cin;using std::cout;using std::endl;using std::tolower;long factorial(int N);int main(){int N = 0; //factorial of Nchar command = 'n';do{cout > N;cout


1.Write a c program for Fibonacci series?

/*program to calculate factorial of a number*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { long int n; int a=1; clrscr(); printf("enter the number="); scanf("%ld",&amp;n); while(n&gt;0) { a*=n; n--; } printf("the factorial is %ld",a); getch(); }


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


Program for finding the factorial of the two given number using constructor?

kjhk


Write a recursive procedure to compute the factorial of a number?

#include &lt;iostream&gt; using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number&lt;1 number&gt;10) { cout &lt;&lt; "Enter integer number (1-10) = "; cin &gt;&gt; number; } // Calculate the factorial with a FOR loop for(i=1; i&lt;=number; i++) { factorial = factorial*i; } // Output result cout &lt;&lt; "Factorial = " &lt;&lt; factorial &lt;&lt; endl;


Programming to calculate a factorial number?

double factorial(double N){double total = 1;while (N > 1){total *= N;N--;}return total; // We are returning the value in variable title total//return factorial;}int main(){double myNumber = 0;cout > myNumber;cout


Write the program that display the factorial of a number?

/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */ #include &lt;stdio.h&gt; int main ( ) { int n , factorial = 1 ; printf ( "enter the value of n\n") ; scanf ( "%i" , &amp; n ) ; while ( n != 0 ) { factorial *= n ; n -- ; } printf ( "The factorial of n is\n%i\n" , factorial ) ; return 0; }


How do you calculate factorial without calculator?

Factorial is calculated by taking the number and multiplying it continually by 1 less than that until you finally multiple by 1. For example 6! = 6x5x4x3x2x1 = 720


How do you create factorial program in qbasic?

since factorial is for example , the factorial of 5 = 5 (5-1)(5-2)(5-3)(5-4) that means the last number to subtract from 5 is 4 , which is (n-1) ie the factorial of any number is (n-0)(.............)(n-(n-1)) to write this , 5 REM to calculate the factorial of any number 6 DIM fac AS INTEGER LET fac = 1 10 INPUT "enter the number to find its factorial "; a ' variable a 15 FOR b = 0 TO (a-1) 'numbers that will be subtracted from the " a" 20 c= a -b 'each number in the factorial calculation 25 fac = fac * c 'to compute each multiplication in the factorial 30 NEXT b 35 PRINT 'to leave a line 40 PRINT fac 45 END note this due to some unattained raesons works for numbers 0 to 7


7 Write a C program to compute the factorial of a number using for loop?

int factorial(int n) { int i; int f=1; for(i=2;i&lt;=n;++i) f*=i; return f; }


What is factory or factorial?

Factorial for number N is N x N-1 x N-2 X N- (N-1). e.g. if you need to calculate factorial for 5 then compute 5 x 4 x 3 x 2 x 1.