Challenge : Automorphic Number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 48

Challenge : Automorphic Number

An automorphic number, also known as an automorph, is a number n whose square ends in n. For instance 5 is automorphic, because 5*5 = 25, which ends in 5. Write a code that shows all the Automorphic Numbers from 1 up to n.

12th Oct 2017, 4:53 PM
Binyam Equar
Binyam Equar - avatar
63 Answers
+ 21
I made the code in c++: https://code.sololearn.com/cx1cYBlw64KP And I calculated 18 automorphic numbers: 1: 1 2: 5 3: 6 4: 25 5: 76 6: 376 7: 625 8: 9376 9: 90625 10: 109376 11: 890625 12: 2890625 13: 7109376 14: 12890625 15: 87109376 16: 212890625 17: 787109376 18: 1787109376 I think, there are two numbers in range between 10^n and 10^(n-1) and these numbers end with the same digits. If so, I wrote the code supported big numbers: https://code.sololearn.com/ce5RV8P5vpTc It calculate so many numbers as you want. Update: the numbers are sorted in ascending order
15th Oct 2017, 3:52 PM
Vladimir Dabarov
Vladimir Dabarov - avatar
24th Feb 2018, 10:37 PM
MeanMachine
MeanMachine - avatar
13th Oct 2017, 7:34 AM
David Akhihiero
David Akhihiero - avatar
12th Oct 2017, 9:49 PM
Vukan
Vukan - avatar
+ 18
JavaScript: var a = prompt("") - 0; if (((a * a) + "").endsWith(a + "")) alert(a + " is an Automorphic Number.");
12th Oct 2017, 5:18 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
19th Mar 2018, 7:16 PM
Danijel Ivanović
Danijel Ivanović - avatar
13th Oct 2017, 5:10 AM
m abrate
m abrate - avatar
12th Oct 2017, 10:54 PM
Binyam Equar
Binyam Equar - avatar
+ 11
https://code.sololearn.com/c5x0Du9pyDij/?ref=app
13th Oct 2017, 1:02 PM
Ekansh
12th Oct 2017, 5:29 PM
Kartikey Sahu
Kartikey Sahu - avatar
+ 10
https://code.sololearn.com/c9QvMV9wTZgO/?ref=app
13th Oct 2017, 1:54 AM
qwerty
qwerty - avatar
+ 10
here's my try used @yash's algorithm. https://code.sololearn.com/cBUaUG6DrWu3/?ref=app
13th Oct 2017, 8:03 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 10
Thanks for the challenge. Here's my try in one line... https://code.sololearn.com/cAFYbiP4l9Jd/?ref=app
13th Oct 2017, 3:04 PM
LukArToDo
LukArToDo - avatar
+ 9
@Yash Thanks for the algorithm!
13th Oct 2017, 4:53 AM
qwerty
qwerty - avatar
+ 9
Here is my code.. I tried it and it turns out there are very few of them. https://code.sololearn.com/W73HoO96jX8b/?ref=app
13th Oct 2017, 10:50 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
13th Oct 2017, 12:32 PM
Alexey Zlo
Alexey Zlo - avatar
+ 9
Here is mine. Large Ns (here 12345678901234567890123456789) without problem thanks to the method that 'grow' the numbers list. Also can give you the Kth automorphic (works for k=1000 which has 563 digits and larger values) https://code.sololearn.com/cm760dHg3ELr/?ref=app Here is the 1800th automorphic number calculated with this code: 701117131278125400133690086034889084364023875765936821979626181917833520492704199324875237825867148278905344897440142612317035699548419499444610608146207254036559998271588356035049327795540741961849280952093753026852390937562839148571612367351970609224242398777007574955787271559767413458997537695515862718887941516307569668816352155048898271704378508028434084412644126821848514157729916034497017892335796684991447389566001932545827678000618329854426232827257556110733160697015864984222291255485729879337147866323172405515756102352543994999345608083801190741530060056055744818709692785099775918050075416428527708162011350246806058163276171676765260937528056844214486193960499834472806721906670417240094234466197812426690787535944616698508064636137166384049029219341881909581659524477861846140912878298438431703248173428886572737663146519104988029447960814673760503957196893714671801375619055462996814764263903953007319108169802938509890062166509580863811000557423423230896109004106619977392256259918212890625
14th Oct 2017, 12:47 PM
VcC
VcC - avatar
12th Oct 2017, 5:06 PM
Tim Thuma
Tim Thuma - avatar
12th Oct 2017, 5:33 PM
Tim Thuma
Tim Thuma - avatar
+ 7
nice one @yash
13th Oct 2017, 5:55 AM
Saurabh Tiwari
Saurabh Tiwari - avatar