Most voted "factorial" questions
For questions involving factorial (denoted by n!), the product of consecutive integers from one to an integer n, and its applications in programming.
Learn more…23 questions
Sort by count of
-
9
votes5
answers8188
viewsBest factor calculation algorithm
So I’m learning to develop in Java. The teacher asked me to develop a method for Factorial. And also show on the screen what is happening, for example: 3! = 3 X 2 X 1 = 6 In fact, I made it happen,…
-
6
votes1
answer41
viewsMy factorial function does not return the expected value! Language C
My teacher is starting to pass functions, and asked us to do a factorial function of a number, but it always returns the wrong value and I do not know what happens. Code: int fatorial(int n) { int…
-
5
votes2
answers648
viewsHyperfactor in C by recursion
I’m trying to make a program with a recursive function to return a hyperfactor of a number in C, but the only value the function returns is 1. Where I’m missing? #include <math.h> #include…
-
5
votes3
answers182
views -
2
votes1
answer629
viewsProgram in python regarding the factor of odd numbers up to the one typed by the user
I must ask the user to enter an odd number and return on the screen the sum of the factorial of all the odd numbers until the one typed by the user. I did the part that validates if the number typed…
-
2
votes1
answer55
viewsFactorization algorithm in C
When creating a number factor algorithm with while I see that by input of the number 21 onwards, the result is wrong -negative. #include <stdio.h> long int i=1, ii=1, num, fat=1, somatorio;…
-
1
votes1
answer101
viewsn >= 1 in the while condition returns no value
Good night. I’m starting to learn Java and I made a program with swing that calculates the factorial of a number. I did using while, and in the condition, I tried to do with the condition (n >=…
-
1
votes3
answers637
viewsMake PHP print the result of the Factorial class
<?php class Fatorial { function calcular(){ $fat = $_GET['fat']; $resultado = 1; for($i = $fat; $i >= 1; $i--){ $resultado *= $fat; $fat--; return $resultado; } } } # Instancia a classe…
-
1
votes2
answers7697
viewsWrite each step of a factorial calculation
I have a piece of code that calculates the factorial of a number in Javascript, but I wanted it to return the steps of each calculation, ex: 3! = 1x2x3 = 6 Follow the code I made. I tried "printar"…
-
1
votes3
answers444
viewsFactorial from 0 to 20 using For
I need to do the following exercise: "Using the for loop, calculate and print the factorial of all numbers between 0 and 20. Use Double type. Ex: 0! =1 1! =1 2! = 2 ... 20! = 2432902008176640000"…
-
1
votes3
answers676
viewsFactor of a number chosen by the user
I’m not getting to be factorial expression, which is: 1 + (1/1! ) + (1/2! ) + (1/3! ) + ... + (1/n!) Whereas the number n is entered by the user. My code: Console.WriteLine("A expreção 1 + (1/1!) +…
-
1
votes2
answers116
viewsHow to create a factorial function using the 'for' counter?
Let’s get to the point: I would like to create a factorial function using the counter for calculating the factor of the parameter numero. Remembering that 0! = 1 and 1! = 1. My code is like this:…
-
0
votes2
answers3540
viewsFactor factor in python,
Guys, I’m new to programming, and doing exercises I came across the following question: Make a program that calculates the factorial of an integer number provided by the user. Ex.: 5!=5.4.3.2.1=120…
-
0
votes1
answer100
viewsOdd results when calculating factorial
I can’t find the error in my code. When I put numbers smaller or equal to 12 my program gives the right result, but from the number 13 the values come out wrong and I can not know why. What’s the…
-
0
votes1
answer2683
viewsHow to factor n! or ! n?
How to factor a number? n! or ! n Example: Let’s take x = 5 x = input('Digite um número inteiro: ') i = 1 while i <= x: for i in range(x): i = i + 1 a = [] a.append(i) print(a) break Since the…
-
0
votes1
answer396
viewsHow to calculate the factorial of a list of integers using thread?
Given an A vector of size N with only positive integers, calculate the factorial of each of them and store the result in a vector B. To calculate the factorial, use the following function: def…
-
0
votes2
answers477
viewsI need help to calculate the factorial in ascending and descending order in an equation!
I need to resolve this question: Make a program that reads the number of terms and a positive value for X. Calculate and show the value of the following series: * S = (-X2/! 1) (+X3/2! ) (-X4/3! )…
-
0
votes1
answer35
viewsFactorial calculation without finishing the program
How would I make this algorithm not to terminate the program and allow me to write other numbers to calculate the factorial? I’ve tried putting one while, or do while, but in no way works, because…
-
0
votes1
answer76
viewsHelp with recursive function in Python
I am a beginner with a lot of difficulty in understanding the recursive function, I know it is a function that calls itself, but I can not make it work happily, in the exercise practiced in class,…
-
0
votes0
answers59
views -
-1
votes0
answers31
viewsJava - problem when factorial using while
The idea is to type I type 3 numbers and calculate the factorial of each number. But I didn’t understand why the variable is keeping the value, for example. String entra; int cont = 1; int numero =…
-
-2
votes1
answer523
viewsStructure of Repetition in Python
I need to solve the following equation in Python N is an integer and positive value. Calculate and show the value of E according to the following formula: E = 1 + 1/1! + 1/2! + 1/3! + ... + 1/N! My…
-
-2
votes3
answers869
viewsFactorial in C, beginning of programming
include stdio.h include stdlib.h include math.h int main() { int n, prod=1,x; printf ("Digite um numero:"); scanf ("%D", &n); for (=1; x<=n; x++) { Prod*= x; } printf ("Fat= %D\n", prod);…