Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
This tag is for challenges involving the factorial of a number, the product of the numbers from 1 to n
3
votes
How many trailing zeros in the hyperfactorial?
05AB1E, 16 10 bytes
LDmTªPγθg<
-6 bytes thanks to @lyxal.
Actually calculates \$H(n)\$ and counts the amount of trailing 0s, so this is a much slower approach. Still valid though, since the new 05AB1 …
3
votes
Repeated! Factorials!
Java 10, 44 bytes
f->b->{int r=1;for(;b>0;b-=f)r*=b;return r;}
Takes the factorial as first input, base as second.
Try it online. … integer return-type
int r=1; // Result-integer, starting at 1
for(;b>0; // Loop as long as the base is still larger than 0
b-=f) // After every iteration: decrease the base by the factorial …
5
votes
Repeated! Factorials!
91 bytes
[S S S T N
Push_1][S N
S _Duplicate_1][S N
S _Duplicate_1][T N
T T _Read_STDIN_as_integer_(base)][T T T _Retrieve_base][S S S N
_Push_0][T N
T T _Read_STDIN_as_integer_(factorial … base = base - factorial
Go to next iteration of LOOP
function PRINT_RESULT:
Print result as integer to STDOUT …
10
votes
Bad factorial joke
# Take the factorial of it (strings remain the same)
s # Swap to get the duplicate value again
> # Increase it by 1 (strings remain the same)
η … # Reverse it
J # And join them together to a single string
M # And then push the largest value on the stack
# (which is either the factorial-integer …
1
vote
Implement the Torian
05AB1E (legacy), 5 bytes
FL}˜P
Port of @Lynn's Jelly answer, so make sure to upvote him/her as well!
Try it online or verify the first \$[0,7]\$ test cases.
Explanation:
F # Loop the (implicit) i …
5
votes
Repeated! Factorials!
05AB1E, 10 8 7 bytes
ݦRIιнP
Input as two separated inputs: first input being base; second input being factorial. … factorial=8: [[10,2],[9,1],[8],[7],[6],[5],[4],[3]]
# i.e. base=420, factorial=30: [[420,390,360,...,90,60,30],[419,389,359,...],...] …
2
votes
Additional facts!
Java 8, 141 136 134 bytes
s->{float q=s.split("!",-1).length,n=new Float(s.split("!")[0]),i=n,r=n;for(;--i>0;r=q<3?i*r:q<4?i+r:q<5?i-r:i/r);return n<1&q<3?1:r;}
-5 bytes (141 → 136) thanks to @Carlo …
1
vote
The vanilla factorial challenge
# Get the factorial (aka gamma(n+1)) of the (implicit) input-integer
# (output the entire stack joined together implicitly as result) …
1
vote
Pseudofactorial
05AB1E, 3 bytes
L.¿
Pretty similar as most golfing languages.
Try it online or verify all test cases.
Explanation:
L # Push a list in the range [1, (implicit) input]
.¿ # Pop and push the LCM ( …
1
vote
Factorials and never ending cycles!
return-type
int s=0; // Sum
for(String i:(n+"").split("")) // Loop over the digits of `n`
s+=f(new Long(i)); // And add the factorial … } // End of separate method (1)
long f(long x){ // Separate method (2) with long parameter and long return-type (calculates the factorial …
6
votes
A Note on N!
# Get the factorial of the current integer
IÅ? # And check if it starts with the input
# (after which the result is output implicitly) …
2
votes
Accepted
Factorials of primes decomposition
# Take the factorial on the second
s # Swap so the other is at the top
m # Exponent the two together
}P # After the map: take the product of the values
I # Push the … input
.E # Evaluate it as Elixir code, which calculates the value for factorial
# inputs and will keep integer inputs unchanged
Q # Check if they're the same
}í # After …