+ 13

Challenge :: Smallest Number With N Divisors. All language.

Divisor - A number that divides into another without a remainder. I.e. divisors of 40 = 1,2,4,5,8,10,20,40 count = 8 divisors of 24 = 1,2,3,4,6,8,12,24 count = 8. There are a lot of numbers with exact 8 divisors but 24 is smallest. So 24 is smallest number with exact 8 divisors. Create a program So if u enter n = 8 output should be 24. for help https://oeis.org/A005179 Happy Coding

27th Nov 2017, 4:42 PM
Uttam
Uttam - avatar
17 Answers
27th Nov 2017, 7:57 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 34
//not a code , but here is my approach to the question , hope u will like it 👉1)mathematical approach //when u don't hv code & u asked for answer any number(obviously natural here) can be expressed as product of prime numbers ie N= a^x . b^y .c^z ..... & so on //where a,b,c ... are prime //so number of divisors of N will be n = (x+1). (y+1). (z+1) .... & so on //example :: 24=2^3 . 3^1 //so no. of divisors of 24 are (4.2) = 8 so when u were provided with n , then divide n between prime no.'s such that u get least value of N example ::: when n=8 (ie 2×2×2 or 4×2 or 8×1 ) , for getting least value of N , we must focus on lower primes first , so 2^1 . 3^1. 5^1 or 2^3.3^1 or 2^7.3^0 //ie 30 , 24,128 can have total 8 factors & 24 is the smallest , hence thats the answer 👉2)code approach //i know java only, so i will talk about what would my approach in java u got n as input from the user //now start a loop from N=1 , make method for calculating no. of factors (all factors will be <=N/2) , when no. of factors comes out to be equal to n , come out of the loop & print N as the answer //as we started from 1 , it will be lowest obviously //☺👍✌ extra information also when N=xy=a^q . b^w . c^e ... //where a,b,c ... are prime //then possible ordered pairs of x,y will be (q+1). (w+1). (e+1) ... example ::: 24 can be expressed as xy in 8 ways //x,y natural number bcz 24=2^3 . 3^1 //ie 4.2 =8 ways {(1,24),(24,1),(2,12),(12,2),(3,8), (8,3), (4,6), (6,4)} //thats simple combiantions u can make urself , there will be (q+1) ways of choosing a , w+1 ways for choosing b & so on //nothing special 😉
27th Nov 2017, 6:46 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
27th Nov 2017, 6:08 PM
Tim Thuma
Tim Thuma - avatar
27th Nov 2017, 6:12 PM
sayan chandra
sayan chandra - avatar
+ 7
Note that if p has prime factorisation: p=a^n1*b^n2*... p has (n1+1)(n2+1)... factors
28th Nov 2017, 4:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
28th Nov 2017, 12:53 PM
Kartik
Kartik - avatar
+ 5
@Yash Thatte, You are right.
27th Nov 2017, 6:22 PM
Uttam
Uttam - avatar
27th Nov 2017, 7:39 PM
Αητοιπe
Αητοιπe - avatar
+ 4
One liner - and funny use of python generators. https://code.sololearn.com/cJ7y5CfumVhb/?ref=app
27th Nov 2017, 8:22 PM
VcC
VcC - avatar
+ 4
Cool challenge! My attempt in Ruby: https://code.sololearn.com/cg61Tb2e9DA4/?ref=app
27th Nov 2017, 9:54 PM
André
André - avatar
+ 4
@Vasudev Sharma You should make your shared codes PUBLIC.
30th Nov 2017, 7:37 PM
Kartik
Kartik - avatar
+ 3
Other version using Pegasus' remark. Work for difficult values for n like 26 (12288) , 31 (n=1073741824), 138 (answer=188743680) or 274 (answer is 261336857795280739939871698507597986398208) https://code.sololearn.com/cPe5zS6E40uu/?ref=app
28th Nov 2017, 11:15 PM
VcC
VcC - avatar
+ 3
Oooops... Version was not public. Here it is Other version using Pegasus' remark. Work for difficult values for n like 26 (12288) , 31 (n=1073741824), 138 (answer=188743680) or 274 (answer is 261336857795280739939871698507597986398208) https://code.sololearn.com/cPe5zS6E40uu/?ref=app
29th Nov 2017, 6:25 PM
VcC
VcC - avatar
+ 3
https://code.sololearn.com/cCPCToS11woL/?ref=app
30th Nov 2017, 5:52 PM
Vasudev Sharma
Vasudev Sharma - avatar
27th Nov 2017, 7:56 PM
Paul
Paul - avatar
- 1
I have this exercise written in c ++. I followed the idea above but got run over time. I don't know what to do with it anymore. help me
27th Apr 2020, 4:39 PM
sushi
sushi - avatar