Skip to main content

Questions tagged [factorial]

This tag is for challenges involving the factorial of a number, the product of the numbers from 1 to n

Filter by
Sorted by
Tagged with
4 votes
1 answer
242 views

Convert real numbers between factoradic and positive integer bases

This prompt asked you to convert back and forth to factoradic, but is very limited in scope (only decimal integers from 0 to 10!-1). Your task in this challenge is to reach just a bit further and ...
guest4308's user avatar
  • 1,458
15 votes
14 answers
2k views

How many trailing zeros in the hyperfactorial?

We have a challenge to calculate the hyperfactorial and one to count the trailing zeros of the factorial, so it seems logical to put them together and count the trailing zeros in the hyperfactorial. ...
Toby Speight's user avatar
  • 6,508
8 votes
7 answers
710 views

Factorials of primes decomposition

You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers. For example ...
DialFrost's user avatar
  • 5,107
18 votes
3 answers
653 views

Find a factorial with n trailing zeros, quickly

Problem A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true ...
Wheat Wizard's user avatar
  • 100k
4 votes
1 answer
264 views

Calculate the (n x "super")factorial [duplicate]

Introduction Factorials are one of the most frequently used examples to show how a programming language works. A factorial, denoted \$n!\$, is \$1⋅2⋅3⋅…⋅(n-2)⋅(n-1)⋅n\$. There is also the ...
astroide's user avatar
  • 563
22 votes
22 answers
3k views

Implement the Torian

The Torian, \$x!x\$, of a non-negative integer \$x\$ can be recursively defined as $$ x!0 = x \\ x!n = \prod^x_{i=1} i!(n-1) = 1!(n-1) \times 2!(n-1) \times \cdots \times x!(n-1) $$ The Torian is then ...
caird coinheringaahin g's user avatar
20 votes
9 answers
633 views

Zeroes at end of \$n!\$ in base \$m\$

Related: Zeroes at the end of a factorial Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$. Or in other words: For given integers \...
tsh's user avatar
  • 35.6k
57 votes
154 answers
8k views

The vanilla factorial challenge

Task Given a non-negative integer \$n\$, evaluate the factorial \$n!\$. The factorial is defined as follows: $$ n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases} $$ Rules All default I/...
Bubbler's user avatar
  • 78.4k
20 votes
9 answers
666 views

Prime Modified Z-Factorials

Let me explain one by one the above terms... We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros. So, \$\text{Z-Factorial}(30)\$...
ZaMoC's user avatar
  • 24.9k
22 votes
39 answers
4k views

Reverse factorial function

Given a number n, find x such that x! = n, where both x and n are positive integers. Assume the input n will always be the factorial of a positive integer, so something like n=23 will not be given as ...
Adam Abahot's user avatar
38 votes
19 answers
7k views

Bad factorial joke

Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign. Task Your task is to write a program that receives a sentence ...
RGS's user avatar
  • 14.1k
39 votes
41 answers
6k views

Repeated! Factorials!

Not to be confused with Find the factorial! Introduction The factorial of an integer n can be calculated by $$n!=n\times(n-1)\times(n-2)\times(...)\times2\times1$$...
Jitse's user avatar
  • 7,734
32 votes
21 answers
2k views

A ​Note ​on ​N!

J. E. Maxfield proved following theorem (see DOI: 10.2307/2688966): If \$A\$ is any positive integer having \$m\$ digits, there exists a positive integer \$N\$ such that the first \$m\$ digits of \$N!...
flawr's user avatar
  • 43.9k
1 vote
3 answers
906 views

Finding Factorials with Gamma [duplicate]

Introduction We know that the factorial notation is valid for all natural numbers. However, Euler had extended it for all positive real numbers, as well as for complex numbers by defining a function, ...
Manish Kundu's user avatar
  • 5,290
16 votes
5 answers
978 views

Factoring factorials

Today in my statistics class, I found that some factorials can be simplified when multiplied together! For example: 5! * 3! = 5! *3*2 = 5! *6 = 6! Your job: Given ...
tuskiomi's user avatar
  • 3,831
17 votes
21 answers
2k views

Additional facts!

In mathematics, the factorial, shortened "fact" of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! is 1 * 2 * 3 * 4 * 5 = 120 ...
Stewie Griffin's user avatar
12 votes
7 answers
759 views

Do two numbers contain unique factorials?

Break two numbers up into their factorials; if they share any, return a falsey value. Otherwise, return a truthy value. (inspired by this recent question) In other words, write each input number as ...
Greg Martin's user avatar
  • 16.2k
37 votes
30 answers
4k views

Factorials and never ending cycles!

As you may know it, the factorial of a positive integer n is the product of all the positive integers which are equal or smaller to ...
user avatar
195 votes
64 answers
31k views

Mathematics is fact. Programming is not

In mathematics an exclamation mark ! often means factorial and it comes after the argument. In programming an exclamation mark ! ...
Calvin's Hobbies's user avatar
27 votes
49 answers
4k views

Big numbers: Ultrafactorials

Ultrafactorials The ultrafactorials are a sequence of numbers which can be generated using the following function: $$a(n) = n! ^ {n!}$$ The resulting values rise extremely quickly. Side note: This is ...
devRicher's user avatar
  • 1,659
28 votes
58 answers
5k views

Factorial digit sum

The challenge is to calculate the digit sum of the factorial of a number. Example Input: 10 Output: 27 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of ...
george's user avatar
  • 1,792
46 votes
44 answers
3k views

Pseudofactorial

There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it'...
Tony Ruth's user avatar
  • 761
39 votes
62 answers
6k views

Zeroes at the end of a factorial

Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any ...
Arcturus's user avatar
  • 7,387
22 votes
10 answers
1k views

Last Nonzero Digits of a Factorial in Base

You should write a program or function which given three positive integers n b k as input outputs or returns the last k digits ...
randomra's user avatar
  • 20.9k
1 vote
4 answers
733 views

Memory is Expensive [closed]

You are a robot. You are stranded in a small cage with weird humans wearing weird suits looking at you. Your solar panel is malfunctioning, and your energy is running out. On the wall there is a ...
matultimate's user avatar
14 votes
16 answers
8k views

How much can you quickly multiply?

With the recent Python bashing, here's an attempt to show Python's strengths. Your challenge is to write a program that calculates the factorial of as high a number ...
user80551's user avatar
  • 2,608
31 votes
10 answers
5k views

Calculate the inverse of factorial

Write the shortest code that will take any real number greater than 1 as input and will output its positive inverse factorial. In other words, it answers the question "what number factorial is equal ...
Jens Renders's user avatar
  • 1,588
63 votes
38 answers
9k views

Factorial in haiku!

Task Create a program that calculates the factorial of a number using no built-in factorial functions. Easy? The catch is that you must write your entire program (including testing it) in haiku form. ...
TheDoctor's user avatar
  • 7,981
28 votes
19 answers
5k views

Last non-zero digit of n!

Given an integer 1 ≤ N ≤ 1,000,000 as input, output the last non-zero digit of N!, where ! is the factorial (the product of all numbers from 1 to N, inclusive). This is OEIS sequence A008904. Your ...
fR0DDY's user avatar
  • 4,597
92 votes
217 answers
23k views

Find the Factorial!

Create the shortest program or function that finds the factorial of a non-negative integer. The factorial, represented with ! is defined as such $$n!:=\begin{...
Kevin Brown-Silva's user avatar