+ 10
🔥🔥🔥 hard challenge()
Find the smallest Number such that if it's RIGHTMOST digit is placed at the BEGINNING, The new Number so formed is precisely 50% larger than the original Number? Hint: use a C# or any other program to find the correct answer or the longer trial and error method. ...good luck!
9 Réponses
+ 8
https://code.sololearn.com/cpmuEsS2VfMY/#py
Run the code to find the answer :D
+ 10
I'm late 😞. Here's a JS solution 🙋.
https://code.sololearn.com/WO3Co0TYK73y/?ref=app
+ 8
That's awesome @Visph.
+ 7
@Sheena Singh:
Much efficient way to do:
n = 10
m = 0
while int(m) != 1.5 * n:
n += 1
m = str(n%10)+str(n//10)
print(n)
+ 5
@Nomeh Uchenna Gabriel wrote:
<< That's awesome @Visph. >>
Awesome but not 'best answer'? ;P
+ 5
@Krishna ~Wow 👏👏👏, this is too great! I never thought of the harder JavaScript version.
+ 3
@Baptiste:
But more verbose ^^ (even if mine should probably been improved ;))
0
@visph
Even more efficient (no str/int)
n=10
m=0
dec=10
while (n%10*dec+n//10)!=1.5*n:
n+=1
if n>=dec*10:
dec*=10
print(n)
0
@visph Yes of course more verbose, but as we do not convert integer to strings each time, it stays more efficient ^^
I did not manage to make it less verbose without passing the number to string as you did