Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I do not find this code "Best Practices" or "Clever". There are two bugs in the solution.
Bug 1: Deadlock
With some input values variable v will overflow, become negative and the while loop will go in deadlock.
Test with the max value for a 64-bit integer.
testequal(9223372036854775807, -1);
Bug 2: Precision loss with double conversion
The inputs to pow function are converted to double and the output is converted back to integer. A double can't represent whole numbers bigger than 2^53.
Test with the maximum number of squares possible for an 64-bit integer.
testequal(9223193340756366400, 77935);