CHALLENGE : Find and print the nth "Highly Composite Number(Anti-Prime)" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

26th Aug 2017, 6:37 PM
Mehmet
Mehmet - avatar
10 Answers
26th Aug 2017, 8:16 PM
Αητοιπe
Αητοιπe - avatar
+ 6
https://code.sololearn.com/cTofCi0j6PcF/?ref=app
27th Aug 2017, 3:10 AM
hamletmun
hamletmun - avatar
+ 2
@Antoine Well done :)
26th Aug 2017, 9:06 PM
Mehmet
Mehmet - avatar
27th Aug 2017, 11:32 AM
Sivan Tal
Sivan Tal - avatar
+ 2
Here you go. Checks for valid input. https://code.sololearn.com/cIi867PTy8Yk/?ref=app
19th Sep 2017, 4:08 AM
Vari93
Vari93 - avatar
+ 1
And this is my answer to my own challenge. https://code.sololearn.com/WBcT32m7zv0Z/#js
27th Aug 2017, 7:30 AM
Mehmet
Mehmet - avatar
+ 1
why n//2+1 when you can have n directly while calculating divisors @hamletmun
27th Aug 2017, 1:49 PM
Balaswamy
Balaswamy - avatar
+ 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..
27th Aug 2017, 1:52 PM
Sivan Tal
Sivan Tal - avatar
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 ;-)
27th Aug 2017, 1:57 PM
Sivan Tal
Sivan Tal - avatar
0
TRY THIS BRAND NEW CHALLENGE AND GET FRESH.. https://www.sololearn.com/discuss/666260/?ref=app
28th Aug 2017, 5:41 PM
sayan chandra
sayan chandra - avatar