answersLogoWhite

0

What is a factorial loop?

User Avatar

Anonymous

15y ago
Updated: 8/18/2019

An example in Java, to compute 10!:

int factorial = 1;

for(int i = 1; i < 11; i++) {

factorial *= i;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you find factorial 5 in C programming?

to find the factorial we declare a variable n and initialize its value to 1 initiate a loop for example a for loop and multiply the numbers upto 5 code:- for(i=1,n=1;i&lt;=5;i++) { n=n*i; }


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 } }


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; }


Find factorial at given number using do while loop?

Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:function factorial(n)result = 1factor = 1while factor


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;


Factorial in c program using for loop?

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


Write a program using while loop?

//program to find the factorial value f any number using while loop #include&lt;stdio.h&gt; void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&amp;n); i=n; while (i&gt;=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user


How do you find greatest factor of a number which is a factorial number in c language?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; main() { int f=1,i=1,n; clrscr(); printf("\n Enter factorial value"); scanf("%d",&amp;n); for(;i&lt;=n;i++) { f=f*i; } printf("\n The factorial value=%d",f); getch(); }


What is the most efficient way to implement a factorial algorithm in a programming language?

The most efficient way to implement a factorial algorithm in a programming language is to use an iterative approach rather than a recursive one. This involves using a loop to multiply the numbers from 1 to the given input number to calculate the factorial. This method is more memory-efficient and faster than using recursion.


What is the value of 9 factorial plus 6 factorial?

The value of 9 factorial plus 6 factorial is 363,600


How to use for loop in vhdl code?

A loop statement is used to iterate through a set of sequential statements. The syntax of a loop statement is [ loop-label : ] iteration-scheme loop sequential-statements end loop [ loop-label ] ; There are three types of iteration schemes. The first is the for iteration scheme that has the form for identifier in range An example of this iteration scheme is FACTORIAL := 1; for NUMBER in 2 to N loop FACTORIAL := FACTORIAL * NUMBER; end loop; The body of the for loop is executed (N-1) times, with the loop identifier, NUMBER, being incremented by I at the end of each iteration. The object NUMBER is implicitly declared within the for loop to belong to the integer type whose values are in the range 2 to N. No explicit declaration for the loop identifier is, therefore, necessary. The loop identifier, also, cannot be assigned any value inside the for loop. If another variable with the same name exists outside the for loop, these two variables are treated separately and the variable used inside the for loop refers to the 34loop identifier. The range in a for loop can also be a range of an enumeration type such as type HEXA is ('0', '1', '2', '3', '4', ' 5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'): . . . for NUM in HEXA'('9') downto HEXA'('0') loop -- NUM will take values in type HEXA from '9' through '0'. . . . end loop; for CHAR in HEXA loop -- CHAR will take all values in type HEXA from '0' through 'F'. . . . end loop; Notice that it is necessary to qualify the values being used for NUM [e.g., HEXA'('9')] since the literals '0' through '9' are overloaded, once being defined in type HEXA and the second time being defined in the predefined type CHARACTER


What is 30 factorial divided by 27 factorial times 3 factorial?

It is 4060.