/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */
#include <stdio.h>
int main ( )
{
int n , factorial = 1 ;
printf ( "enter the value of n\n") ;
scanf ( "%i" , & n ) ;
while ( n != 0 )
{
factorial *= n ;
n -- ;
}
printf ( "The factorial of n is\n%i\n" , factorial ) ;
return 0;
}
Pseudo code+factorial
factorial number Var num= prompt("enter any number "); Var i=1; Var fact=1; for(i=1;i
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
That's not the factorial of any number. For a start, the factorial of any number greater than or equal to 2 is even, because of the factor 2. The factorial of any number greater or equal to five ends with 0. Another answer: I suspect the questioner meant to ask how to write 8*7*6*5*4*3*2*1 as a factorial. If so, then the answer is "8!"
seq 1 2 99
To write a program that calculates the factorial of a number in PHP, you can use a recursive function or an iterative approach. Here’s a simple example using a loop: function factorial($n) { $result = 1; for ($i = 2; $i <= $n; $i++) { $result *= $i; } return $result; } echo factorial(5); // Outputs: 120 This code defines a function that multiplies numbers from 2 up to the given number $n to compute the factorial.
Pseudo code+factorial
write a program to display your name age class schoolname e-mail 2hobby based on choice
int factorial(int n) { int i; int f=1; for(i=2;i<=n;++i) f*=i; return f; }
Write a program which takes any number of days from the user. the program should display the number of years, number of months formed by these days as well as the remaining days.
factorial number Var num= prompt("enter any number "); Var i=1; Var fact=1; for(i=1;i
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
/*program to calculate factorial of a number*/ #include<stdio.h> #include<conio.h> void main() { long int n; int a=1; clrscr(); printf("enter the number="); scanf("%ld",&n); while(n>0) { a*=n; n--; } printf("the factorial is %ld",a); getch(); }
That's not the factorial of any number. For a start, the factorial of any number greater than or equal to 2 is even, because of the factor 2. The factorial of any number greater or equal to five ends with 0. Another answer: I suspect the questioner meant to ask how to write 8*7*6*5*4*3*2*1 as a factorial. If so, then the answer is "8!"
seq 1 2 99
Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.
#include <iostream> using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number<1 number>10) { cout << "Enter integer number (1-10) = "; cin >> number; } // Calculate the factorial with a FOR loop for(i=1; i<=number; i++) { factorial = factorial*i; } // Output result cout << "Factorial = " << factorial << endl;