Challenge: Simple And Easy Number Division | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 26

Challenge: Simple And Easy Number Division

Consider positive integers that are divisible by 7, and are also divisible by 7 when you reverse the digits. For instance, 259 counts, because 952 is also divisible by 7. The list of all such numbers between 0 and 10^3 is: 7 70 77 161 168 252 259 343 434 525 595 616 686 700 707 770 777 861 868 952 959 The sum of these numbers is 10,787. Find the sum of all such numbers betwen 0 and 10^11. Make your program work for an upper limit of 10^N for any N, and be able to efficiently handle N's much larger than 11.

18th Oct 2017, 10:22 AM
GAWEN STEASY
GAWEN STEASY - avatar
18 Réponses
+ 19
/* for those who don't understand the challenge ūüĎá find sum of numbers between 0 and 10^n where n is a positive integer(obviously) , numbers must be of form 7x and its reverse of form 7y , where x,y belongs to set of natural number //hope i explained well , & it makes sense 2 u ‚ėļ */ ‚¨úūüĆĻūüĆĻūüĆĻūüĆĻūüĆĻ‚¨ú ūüĆĻ‚¨ú‚¨ú‚¨ú‚¨ú‚¨ú‚¨ú ūüĆĻ‚¨ú‚¨ú‚¨ú‚¨ú‚¨ú‚¨ú ūüĆĻ‚¨ú‚¨ú‚¨úūüĆĻūüĆĻūüĆĻ //here is my try ūüĎá (& yes , thats v. easy when u understand what is the question ) ūüĆĻ‚¨ú‚¨ú‚¨ú‚¨ú‚¨úūüĆĻ ūüĆĻ‚¨ú‚¨ú‚¨ú‚¨ú‚¨úūüĆĻ ‚¨úūüĆĻūüĆĻūüĆĻūüĆĻūüĆĻ‚¨ú https://code.sololearn.com/cx98ungMZe6w/?ref=app
18th Oct 2017, 10:27 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 16
@gawen , in mine code , time limit exceeded for 10^11 , //but , i have made it to take least time , u can see the code ... if some improvement can be done ... then tell //it will work for 10^3
18th Oct 2017, 12:24 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 15
@Gaurav I mean you have first take number which reverse is also divisible by 7 and then you have to sum that numbers and print it the range should be satisfied any user input
18th Oct 2017, 10:53 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 14
this is my try check it guysūüėäūüėä https://code.sololearn.com/cHGFYya05luZ/?ref=app
20th Oct 2017, 7:54 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 11
Gawen ur question is not too clear
18th Oct 2017, 10:31 AM
David Akhihiero
David Akhihiero - avatar
18th Oct 2017, 3:49 PM
David Akhihiero
David Akhihiero - avatar
+ 8
Don't know if it works or not. You can't run it on code playground because it takes too much memory. Try to run it on a different compiler. https://code.sololearn.com/c1e37LU4Sg40/?ref=app
18th Oct 2017, 2:20 PM
qwerty
qwerty - avatar
+ 7
I made one that I think can do 10^11 but the memory limit exceeded.
18th Oct 2017, 1:46 PM
qwerty
qwerty - avatar
+ 7
Gawen, your code is amazing ūüĎć Here's my try: https://code.sololearn.com/cyEfkvQc12Cy/?ref=app
21st Oct 2017, 9:07 AM
LukArToDo
LukArToDo - avatar
+ 6
gawEINSTEINasy series! ūüėĪūüėĪ
21st Oct 2017, 6:25 AM
Kartikey Sahu
Kartikey Sahu - avatar
18th Oct 2017, 5:16 PM
Natalia
Natalia - avatar
+ 5
https://code.sololearn.com/cZVIXGQTlI9u/?ref=app
18th Oct 2017, 9:19 PM
Curly Fries
Curly Fries - avatar
18th Oct 2017, 6:08 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 3
Here is my try. My code isn't efficient to solve N=11 case in CodePlayground.. https://code.sololearn.com/cGv9UZZkqnCm/?ref=app
19th Oct 2017, 3:49 AM
Hiroki Masuda
Hiroki Masuda - avatar
19th Oct 2017, 11:35 AM
m_sudhu
m_sudhu - avatar
21st Oct 2017, 11:41 AM
Moln√°r Zsolt
Moln√°r Zsolt - avatar
21st Oct 2017, 11:40 AM
Moln√°r Zsolt
Moln√°r Zsolt - avatar
+ 2
https://code.sololearn.com/c6JrqYEeT8eA/?ref=app Will work till 10^1000000 but not completed yet. I just need 2-3 more lines to write which I don't know ūüė•
21st Oct 2017, 11:40 AM
Kartikey Sahu
Kartikey Sahu - avatar