+ 5
👑Challenge: Which Integer has the largest number of divisors?👑
Which integer between 1 and 10000 has the largest number of divisors, and how many divisors does it have? Write a program to find the answers and print out the results. It is possible that several integers in this range have the same, maximum number of divisors. Your program only has to print out one of them.
7 ответов
+ 12
7560 AND 9240 with count of 64 divisors (including 1 and the number itself)
* if getting time limit exceeded error, try again, it might fail from time to time due to a lot of computations
* will try to see if i can optimize it further
edit: optimized by limiting each loop which count number of divisors of n to sqrt(n) + 1 which greatly improves the run time
by doing so, i am basically "losing" half of my results as for divisor 'm' which produce the result:
n / m = c there is also c as a divisor which produces:
n / c = m which i fail to check because
c > sqrt(n) and therefore not included in the initial count check
hence the amount of results should be multiplied by 2
* code should run smoothly for n = 10000
* might get time limit exceeded for n = 100000 but should work sometimes
edit: added prettified printing of the results
https://code.sololearn.com/cK2Hq72gTuip/?ref=app
+ 8
https://code.sololearn.com/cI2GkoIpMEld/#cs
+ 7
Thanks Zephyr Koo, i did it :d
https://code.sololearn.com/cIITkEn77O15/?ref=app
+ 4
Here is my try with java:
https://code.sololearn.com/cQtOg5ZsDK8N
+ 4
See my code -
https://code.sololearn.com/Wk7gbYWPHxN0/?ref=app
+ 3
This is my code:
https://code.sololearn.com/cRF3JFWLpl83/?ref=app