factorial Questions

6

Solved

I need to write a program to input a number and output its factorial's prime factorization in the form: 4!=(2^3)*(3^1) 5!=(2^3)*(3^1)*(5^1) The problem is I still can't figure out how to get th...
Valentijn asked 17/1, 2014 at 22:5

1

To work with complex numbers, I created a struct Cmplx that stores the real and imaginary parts in two separate variables. struct Cmplx { long double real, imag; }; I'm having difficulty computin...
Latashialatch asked 4/6, 2024 at 4:15

14

Solved

What is the most efficient method to evaluate the value of "n choose k" ? The brute force way I think would be to find n! / k! / (n-k)! by calculating each factorial separately. A better ...

11

I've been stucked on this question for a really long time. I've managed to do a single recursive factorial. def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) Double facto...
Exceptional asked 19/1, 2011 at 20:9

3

Solved

Calculate the most right non-zero digit of n factorial efficiently I want to calculate the right most digit of a given number's factorial and print it. What I've done so far is: import math n = int...
Alishiaalisia asked 2/6, 2023 at 7:39

16

Solved

Currently I have this set of code and its meant to calculate factorials. int numberInt = int.Parse(factorialNumberTextBox.Text); for (int i = 1; i < numberInt; i++) { numberInt = numberInt * ...
Rowles asked 16/5, 2013 at 9:26

5

Solved

I am trying to calculate the number of trailing zeros in a factorial. def count(x): zeros = 0 for i in range (2,x+1): print(i) if x > 0: if i % 5 == 0: print("count") zeros +=1 els...
Siobhansion asked 16/11, 2016 at 22:50

6

Solved

I am trying to write a Java program to calculate factorial of a large number. It seems BigInteger is not able to hold such a large number. The below is the (straightforward) code I wrote. public...
Isar asked 24/1, 2012 at 18:57

6

Solved

I am new to Python and currently reading Python 3 for absolute beginner and face following problem. I would like to calculate factorial with procedure. request user to input an non negative num...
Postmistress asked 13/2, 2014 at 8:36

4

Solved

I need to calculate 21 factorial in my project. fn factorial(num: u64) -> u64 { match num { 0 => 1, 1 => 1, _ => factorial(num - 1) * num, } } fn main() { let x = factorial(21);...
Spiraea asked 6/12, 2019 at 3:57

5

I tried to calculate poisson distribution in python as below: p = math.pow(3,idx) depart = math.exp(-3) * p depart = depart / math.factorial(idx) idx ranges from 0 But I got OverflowError: lon...
Decibel asked 23/4, 2013 at 16:20

6

Solved

I have been using this function for calculating factorial numbers in JavaScript: var f = []; function factorial (n) { if (n == 0 || n == 1) return 1; if (f[n] > 0) return f[n]; return f[n]...
Wagonette asked 14/1, 2014 at 23:34

4

Solved

I found FastFactorialFunctions describing a number of algorithms for computing the factorial. Unfortunately, the explanations are terse and I don't feel like sifting through line after line of sour...
Gould asked 17/11, 2009 at 19:55

15

Solved

How can I combine these two functions into one recursive function to have this result: factorial(6) 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 This is the current code for my factorial functi...
Hambley asked 21/12, 2010 at 18:6

1

I want to adjust the function's parameters so that the items don't overlap. I've tried changing the rsize, e.size and gap.size but nothing works. Any ideas?
Serg asked 22/6, 2021 at 21:47

20

Solved

I'm going crazy: Where is the Ruby function for factorial? No, I don't need tutorial implementations, I just want the function from the library. It's not in Math! I'm starting to doubt, is it a st...
Verney asked 12/3, 2010 at 17:20

16

Solved

What is an example (in code) of a O(n!) function? It should take appropriate number of operations to run in reference to n; that is, I'm asking about time complexity.
Stickleback asked 17/10, 2010 at 12:37

11

Solved

Hi I'm trying to write a function to find the factorial product of any given number. For example for factorial (6) I would get the product of 6*5*3*2*1. so for factorial(3) the output would be 6. ...
Foliose asked 1/10, 2014 at 23:49

2

Solved

The following Prolog program defines a predicate fact/2 for computing the factorial of an integer in successor arithmetics: fact(0, s(0)). fact(s(X), Y) :- fact(X, Z), prod(s(X), Z, Y). prod(0, ...

5

Solved

I am trying to write a function that will produce the factorial of a provided integer and then reduce the factorial array (by multiplying each array element). For example: factor(5) >>> [1, 2, 3,...
Sewel asked 3/3, 2016 at 19:5

5

var lookup = {}; function memoized(n) { if(n <= 1) { return 1; } if(lookup[n]) { return lookup[n]; } lookup[n] = n * memoized(n - 1); return lookup[n]; } vs. function fact(n) { if(n ...
Strikebound asked 28/7, 2013 at 6:53

2

Solved

I am trying to implement a tail-recursive factorial calculator but I am still getting a stack overflow. Can anyone help me out in figuring out why? I have read that Java 8 supports Tail call optim...
Heartstrings asked 6/11, 2020 at 15:9

4

Solved

I am trying to make a code for this problem: (Source: https://www.codewars.com/kata/insane-coloured-triangles/train/c) A coloured triangle is created from a row of colours, each of which is ...
Dubose asked 2/12, 2018 at 22:2

10

Solved

When doing this: int x = 100; int result = 1; for (int i = 1; i < (x + 1); i++) { result = (result * i); } System.out.println(result); This is clearly because the result is too big for an in...
Colloid asked 15/3, 2011 at 20:36

12

Having a little trouble trying calculate the number of trailing zeros in a factorial of a given number. This is one of the challenges from Codewars- can't get mine to pass. zeros(12) = 2 #=> 1...
Parotitis asked 1/6, 2014 at 7:40

© 2022 - 2025 — McMap. All rights reserved.