+ 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
25 Respostas
+ 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
+ 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?"!
+ 10
@Burey I guess the square of 1 (1) can separate into one part (1) which, totalled, equals one.
+ 10
@Edward if you havent already, look at my other challenges
+ 8
yes that
+ 8
@Edward yes, for example if it has an odd number of digits
+ 8
So 1 is not a Kaprekar number?
+ 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'
+ 7
I would say of course! It is supposed to be whoever posts first... I say go for it @Burey
+ 7
+ 6
Supersebi3
i got a code ready
can i post?
+ 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
+ 6
@J.G.
according to every google result i have seen 1 is indeed a Kaprekar number
couldn't find a specific explanation
+ 5
https://code.sololearn.com/cFZqYsO0r7wf/?ref=app
final answer
+ 4
oh you beat me to it xD
+ 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
+ 3
this challenge was a lot easier than i thought at first. need more pls :)
+ 2
wait i think i did it. and 1 is a kaprekar according to the wikipedia page
+ 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