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.
This comment is hidden because it contains spoiler information about the solution
hmmm so u can give true to 2 simply by changing when u increase i....
++i good one, didnt thought of that.
To be fair, this question is simply about transforming the mathematical question into a code. If you do not understand the question you won't solve it and this code practice is the best.
if a number is composite then one of its roots will be less than or equal to its square root.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
如果一个数可以被分解为不同的因子,那么必定有一个因子是 <= 这个数的平方根,另一个因子是 >= 这个数的平方根。那么只需要从 2 到此数的平方根找出是否能整除该数的因子,如果能找到,就说明该数不是质数。
because if number isn't didived by prime numbers or all numbers that less than or equal to its square root is a prime
That thread was actually really interesting, thnak you. I will adapt my views, but probably not my coding practice (as this was pounded into my head, it's gonna take some time to unlearn).
But honestly thank you for giving me a chance to learn something ,this was really cool.
While one should refrain from creating a spaghetti control flow, the "single entry, single return" guideline originates from times and reasons long forgotten and it has not much of applicaiton today: https://softwareengineering.stackexchange.com/questions/118703/where-did-the-notion-of-one-return-only-come-from . People stick to it because they like to repeat seemingly authoritative stuff without exactly understanding it. Excessive sticking to Single Return Rule (no more room for Single Entry Rule in modern languages) is usually a cargo cult programming at its best.
The only reason I don't like this, and I know this is just me being pedantic, is the amount of returns. I don't know if there's something processing wise, to be gained from having multiple, as opposed to having just one that returns a variable and the manipulating the variable in stead.
I would love to learn about the various ways, and benefits of each.
I know it's somewhat tied to the term Cyclomatic Complexity, and the measure that "The more returns, the more 'complex' the code. and the simpler the better."
What are your takes on this?
Wow! I forgot about Math.sqrt. I will studying harder
You have trailing spaces in your answer