Cody Problem 58018 asked you to list the Fermi-Dirac primes, which are prime powers with exponents that are powers of 2. As noted there, the name comes from an analogy with particle physics because every number can be written as the product of a unique subset of the Fermi-Dirac primes, in which the Fermi-Dirac primes appear at most once. For example,
.
Write a function analogous to factor(n) that factors the number n into Fermi-Dirac primes. List the Fermi-Dirac primes in ascending order. Take the factorization of 1 to be 1.
Solution Stats
Problem Comments
4 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers8
Suggested Problems
-
Remove any row in which a NaN appears
8768 Solvers
-
Omit columns averages from a matrix
617 Solvers
-
Back to basics 12 - Input Arguments
619 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
2035 Solvers
-
Fix the last element of a cell array
1751 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Ramon's solutions under 49 used pyrun() calls I don't even pretend to understand. My 36 post is straight MATLAB, though I admit I used str2num() rather strongly.
What should be the output for numbers such as 256?
[4 64]? [16 16]?
Or 1024?
[4 256]? [4 4 64]? [4 4 4 16]? [16 64]? [4 16 16]?
Does it have to be a particular pairing(s)? If yes, how so?
Or will any/all of them work?
@Dyuman Here's my two cents:
256 = [256]. [4 64] is not valid since 64 is not a prime power where the exponent is a power of two. [16 16] is out since - I assume - you're supposed to simplify as much as possible. Same for [2 2 2 2 2 2 2 2], [4 4 4 4] and so on. But you're right that this additional requirement is needed to ensure uniqueness.
1024 = [4 256] using the same reasoning.
I added the requirement that the FD primes appear in the factorization at most once. This requirement resembles a difference between the Fermi-Dirac and the Bose-Einstein distributions of particles.