Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks for the explanation. Turns out I was completely wrong. I'm glad someone finally explained it to me.
Found a Wikipedia article that almost mirrors the wolfram article, but it left out the 1 which is probably another subtle detail lost...
https://en.wikipedia.org/wiki/Table_of_prime_factors#1_to_100
Not sure you can call this readable or clever. It is definitely good code golf though.
So is there something wrong with the tests or the description? Your reply does not seem to address the actual issue.
It seems like you are just trying to defend your previous comment?
I actually said:
I even included "I might have just misunderstood the description?" because of how many people had completed the kata already. I thought this statement conveyed an earnest and polite tone, but for some reason, it was only met with condescension.
Just to be explicit and explain the same thing again. I assumed the terms factor and prime factor are very well understood concepts on here. I am still under the impression that these are fundamental concepts that all but true novices would struggle with. This is a 4 kyu kata, so I believe it is safe to assume it is not meant for true novices. Also, you literally need to understand how to implement integer factorization to even complete this kata.
Read my original comment with the assumption that the audience actually understands all of this. If that is the case, the reasoning should be self evident.
Again. Is there something
definitely wrong with the kata
? It seems apparent to me, but for some reason, you and another high ranking user stated otherwise. I would like to know the "some reason" if I am wrong, or at least have my suspicions confirmed.From my second comment:
Seriously though, was my assumption that these terms should be well understood by people who have completed this kata unreasonable? Feel free to point out where my thought process is wrong. I would honestly welcome it at this point because this entire interaction has confused me.
Yep. Missed something obvious. Thanks.
Based on the condescending replies, I guess I need to explicitly define some terms that I had assumed were well understood on a site such as this.
*Note the bolded terms below
From the description:
In number theory, integer factorization is the decomposition of a composite number into a product of smaller integers. If these integers are further restricted to prime numbers, the process is called prime factorization.
A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers.
I am assuming we can agree that prime factorization is the process for finding prime factors?
Note that there are two issues with calling
107
a prime factor of107
.107
is not smaller than107
1
which is not a prime numberTo be explicit,
107
is already invalid as a factor based on the fact that it is not less than107
. This means it cannot be an integer factor, much less a prime factor. The fact that the other smaller integer of1
is not prime is unnecessary.Maybe I am still wrong, but I am just not able to see it on my own. Instead of another condescending response, maybe provide some helpful information this time around? Also, I have no idea how my original comment warranted such condescension, but that is separate issue.
PS: On second thought, to avoid further condescension, I am just going to include a link that explicitly states the relationship between prime factor and prime factorization.
Writing a number as a product of prime numbers is called a prime factorization of the number... The terms in the product are called prime factors.
For JavaScript
What numbers have
107
as a factor? It feels like the test case might be suggesting107
is its own factor since the sum is exactly107
?I might have just misunderstood the description?
It is not O(n^2). He's using the same counter to grab the range. It is just O(n).
Also, why did everyone remove the steps they used to solve each Bomb? Wouldn't it be more interesting to see those as well as the actual solution?
How did you figure out it was using indexOf?
Technically, the accuracy of the popular solutions falters before x reaches 170, but factorial 171 exceeds the max value of double which is when those solutions completely fail.
Could make this slightly harder by checking with higher inputs (something that exceeds factorial(170)). Right now, this is a bit too straight forward for a 5 kyu.
Not sure why you switch between
c < x
andx > c
randomly through the description. It makes it confusing even though the two statements are equivalent. It could definitely confuse someone on what direction the comparison operation should be.Actually, a lot of computations are done with lookup tables. You might want to learn more about computers before making generalizations about them.
For all the people saying this is not best practice, lookup tables are actually the best practice in the majority of cases where memory is not limited. So unless if you are implementing something without a hardware multiplier, you should not rule out an implementation that uses lookup tables. They don't have to be a one to one table like this one.
Not just vintage games like Doom. Most modern calculators/[cg]pus will use some form of lookup tables for transcendentals. There are performant alternatives when lookup is not available (in memory limited applications like old microcontrollers), but if you have the option, it would make no sense to go for the slower more complicated algorithm. Lookup tables aren't just limited to calculating transcendentals, they are ubiquitous across software and hardware.
Loading more items...