+ 15

CHALLENGE✋: Integers, roots and division

The point is to: Find all the positive integers "n" that are divisible by all the positive integers not larger than the square root of n. Any language is welcomed.

28th Dec 2017, 9:10 AM
Ledio Deda
Ledio Deda - avatar
29 Respostas
+ 11
Odd. The question made perfect sense to me. At least this is how I interpreted it. *Remember to take heed for cases 0 and 1. :> https://code.sololearn.com/cyLCMBAHgdg4/?ref=app
28th Dec 2017, 10:44 AM
Hatsy Rei
Hatsy Rei - avatar
+ 18
recursion only ☺ //a modification can be made to improve code but'll increase the size of code https://code.sololearn.com/cBLVKqmodgX9/?ref=app
1st Jan 2018, 5:50 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 17
(x Ɛ Z : 0 < x < ∞) where x % [1, [(√x)]] == 0 , [.] denotes greatest integer function & and % denotes modulus operator(which we use in java 😂) //in math we state it like this @blackcat1111 /*it would be wrong to say that 0 is included in set of +ve numbers , u can 0 is included in set of non negative numbers */
31st Dec 2017, 8:45 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 16
guys are u all out of the confusion that why 24 is maximum , if not then u can see this link ☺👍 https://publish.pothi.com/preview/?sku=ebook3477
2nd Jan 2018, 12:07 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 14
https://code.sololearn.com/c40R8yE5I1v9/?ref=app
31st Dec 2017, 5:09 PM
Justine Ogaraku
Justine Ogaraku - avatar
28th Dec 2017, 11:15 AM
David Akhihiero
David Akhihiero - avatar
+ 7
@blackcat1111 Absolutely. Unless you haven't understand the challenge properly, or I haven't been clear enough while explaining...
28th Dec 2017, 10:34 AM
Ledio Deda
Ledio Deda - avatar
+ 7
@Martin An example: 32 is not a solution because sqrt(32)=5.something, so 32 has to be divisible by 1, 2, 3, 4 and 5. But 32%5 or 32%3 is not 0. Did you get it now??
28th Dec 2017, 10:36 AM
Ledio Deda
Ledio Deda - avatar
+ 7
@Guarav Agrawal Sorry, haven't done math in two months 😉
31st Dec 2017, 11:02 PM
blackcat1111
blackcat1111 - avatar
+ 5
Based on my understanding of your question: https://code.sololearn.com/cGuulwT0K3Li/?ref=app
28th Dec 2017, 10:53 AM
blackcat1111
blackcat1111 - avatar
+ 5
https://code.sololearn.com/clf0JFFUjFbT/?ref=app
2nd Jan 2018, 12:03 PM
Viraj Singh
Viraj Singh - avatar
+ 4
All? You are sure there is not an infinite quantity of such?
28th Dec 2017, 10:32 AM
blackcat1111
blackcat1111 - avatar
+ 4
@Ledio Deda I shall rephrase the question; please tell me if I am wrong. Find all positive integers (x Ɛ Z : 0 ≤ x < ∞) where x MOD (1.. INT(√x)) == 0.
28th Dec 2017, 10:43 AM
blackcat1111
blackcat1111 - avatar
+ 4
Well @Hatsy Rei found them🎉🎉... Other ways of solution expected...
28th Dec 2017, 10:46 AM
Ledio Deda
Ledio Deda - avatar
+ 4
@blackcat ✅Correct, but in order to avoid time limit exceeded, you can follow a simple maths algorythm to find the larges possible integer "n" who can satisfy the condition...
28th Dec 2017, 10:58 AM
Ledio Deda
Ledio Deda - avatar
+ 4
@VcC Yes, but that kp must be less or equal than sqrt(n). Got it???
28th Dec 2017, 11:01 AM
Ledio Deda
Ledio Deda - avatar
+ 4
@yerucham Absolutely correct!!!👏👏 The only advice is to find the largest possible solution and put the limit to that nr and not 100000. But that is optional...👍
28th Dec 2017, 11:18 AM
Ledio Deda
Ledio Deda - avatar
+ 4
Well, I would let it turn as an infinite loop, to keep the initial logic ... if the thing has to be used as a checker, one shouldn't stop it unless he knows the answer. But the code playground here doesn't like it. https://code.sololearn.com/cJmR8F49KA0X/#py
28th Dec 2017, 6:13 PM
Cépagrave
Cépagrave - avatar
+ 4
https://code.sololearn.com/crqZak5WxYed/?ref=app
6th Feb 2018, 3:47 PM
...
+ 3
@Ledio Deda Thanks for the tip! It was actually pretty easy. Fixed my code now. [Spoilers Alert] Consider the largest number p satisfying the conditions where p MOD (0..q], where q = int(√p). Following the definition of q, p must be q! as p is the largest number satisfying the conditions. Therefore: p = q! where q = int(√p). Hence the largest number is 24.
28th Dec 2017, 11:09 AM
blackcat1111
blackcat1111 - avatar