We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I failed case 6 several times before identifying the problem in my code. My problem was due to a mix use of int and long long. I thought I only needed int for the number being check and long long for its square. Turned out it was risky without careful casting, because when you assign the multiplication of two int's to a long long variable when the multiplication exceeds the int limit, the long long variable only gets the chunked portion available in the int bits. Hope this somehow contributes to the troubleshooting options.
Modified Kaprekar Numbers
You are viewing a single comment's thread. Return to all comments →
I failed case 6 several times before identifying the problem in my code. My problem was due to a mix use of int and long long. I thought I only needed int for the number being check and long long for its square. Turned out it was risky without careful casting, because when you assign the multiplication of two int's to a long long variable when the multiplication exceeds the int limit, the long long variable only gets the chunked portion available in the int bits. Hope this somehow contributes to the troubleshooting options.