+ 10

Irregularly posted coding challenge #5!

This will be similar to number 3. Kaprekar numbers. Read my answer for info. Either: a) Have the user enter a number and check if it's a Kaprekar number or not b) Have the user enter a number n and print the first n Kaprekar numbers c) Have the users enter two numbers n and m and print all Kaprekar numbers between them

28th Apr 2017, 8:27 PM
Supersebi3
Supersebi3 - avatar
25 Respuestas
+ 9
A Kaprekar number is a positive integer where the square of it can be split into two halves, and adding those together, turns back into the initial number. Example: 45 is a Kaprekar number, because: 45² = 2025 You can split 2025 into 20 and 25 20 + 25 = 45
28th Apr 2017, 8:29 PM
Supersebi3
Supersebi3 - avatar
+ 10
@Burey nice code, I like how you designed the page (with info, examples etc) @Edward I like that you took a different challenge instead of the typical "is x a Kaprekar?"!
28th Apr 2017, 9:24 PM
Supersebi3
Supersebi3 - avatar
+ 10
@Burey I guess the square of 1 (1) can separate into one part (1) which, totalled, equals one.
28th Apr 2017, 11:51 PM
J.G.
J.G. - avatar
+ 10
@Edward if you havent already, look at my other challenges
29th Apr 2017, 6:17 AM
Supersebi3
Supersebi3 - avatar
+ 8
yes that
28th Apr 2017, 8:30 PM
Supersebi3
Supersebi3 - avatar
+ 8
@Edward yes, for example if it has an odd number of digits
28th Apr 2017, 8:42 PM
Supersebi3
Supersebi3 - avatar
+ 8
So 1 is not a Kaprekar number?
28th Apr 2017, 9:15 PM
J.G.
J.G. - avatar
+ 8
ty for the heads up @Edward fixed it now by validating that the right side of the pair is not made entirely of '0'
29th Apr 2017, 12:38 AM
Burey
Burey - avatar
+ 7
I would say of course! It is supposed to be whoever posts first... I say go for it @Burey
28th Apr 2017, 9:02 PM
J.G.
J.G. - avatar
28th Apr 2017, 9:04 PM
Burey
Burey - avatar
+ 6
Supersebi3 i got a code ready can i post?
28th Apr 2017, 8:59 PM
Burey
Burey - avatar
+ 6
i have problems with the number 1 as well it's due to the fact its squarr is also one and cannot be divided into two parts so have to make a private case of it
28th Apr 2017, 9:14 PM
Burey
Burey - avatar
+ 6
@J.G. according to every google result i have seen 1 is indeed a Kaprekar number couldn't find a specific explanation
28th Apr 2017, 9:50 PM
Burey
Burey - avatar
28th Apr 2017, 9:20 PM
Edward
+ 4
oh you beat me to it xD
28th Apr 2017, 8:31 PM
Burey
Burey - avatar
+ 3
@burey i just noticed, your code says 100 is a kaprekar. but according to wikipedia its not; 100^2 = 10000 and 100 + 00 does in fact equal 100, but wikipedia says you cant add 0 in the second half of the square
29th Apr 2017, 12:06 AM
Edward
+ 3
this challenge was a lot easier than i thought at first. need more pls :)
29th Apr 2017, 12:44 AM
Edward
+ 2
wait i think i did it. and 1 is a kaprekar according to the wikipedia page
28th Apr 2017, 9:17 PM
Edward
+ 2
Enter 2 numbers, it will return the Kaprekar Numbers between them. It isn't as good as Edwards, but it does work https://code.sololearn.com/cceiiT6pO3M5/?ref=app
28th Apr 2017, 9:32 PM
LordHill
LordHill - avatar