+ 2
CHALLENGE : Find and print the nth "Highly Composite Number(Anti-Prime)"
Hello there, a new challenge awaits you. Highly composite numbers (or anti-primes) are numbers such that the number of divisors of 'n', is greater than any integer's number of divisors below it. Note: HC=Highly Composite FOR EXAMPLE: 1 has only one divisor(since it is the first positive integer, it is considered as HC) 2 has 2 divisors (It is HC because it has more divisors than any number below) 3 has 2 divisors(Not HC) 4 has 3 divisors(HC) 5 has 2 divisors(Not HC) 6 has 4 divisors(HC) The next HC number is the one that has at least 5 divisors. THE TASK is to write a code that will find the n'th HC number and print it. HAVE FUN :) Wiki link: https://en.wikipedia.org/wiki/Highly_composite_number
10 Respuestas
+ 6
https://code.sololearn.com/cTofCi0j6PcF/?ref=app
+ 2
@Antoine Well done :)
+ 2
Here's my solution in Python:
https://code.sololearn.com/cHIOPxRMhLdO
+ 2
Here you go. Checks for valid input.
https://code.sololearn.com/cIi867PTy8Yk/?ref=app
+ 1
And this is my answer to my own challenge.
https://code.sololearn.com/WBcT32m7zv0Z/#js
+ 1
why n//2+1 when you can have n directly while calculating divisors @hamletmun
+ 1
Basically, you can break out the loop when the quotient ia less than the divisor. Given that for each division you add both the divisor and the quotient to the set of divisors.. check out my code if you like an example..
0
indeed humletmun seems to have a bug there, but it doesn't affect the result because he misses one divisor in each number, so the comparison is eventually correct. So it's actually an optimization rather than a bug, assuming he knows what he's doing ;-)
0
TRY THIS BRAND NEW CHALLENGE AND GET FRESH..
https://www.sololearn.com/discuss/666260/?ref=app