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.
Same here ;-;
Author note: I made the length variable because it made the return statements slightly less complicated. In the past, I probably would have created a variable to hold the String that I am returning as well, but based on what I've been seeing on this site thus far, I thought perhaps just having the return statements create the Strings they are returning might be the preferred approach. Any opinions on one approach or the other?
Author comment: How bad should I feel that I had to Google a bunch of stuff to work this one out? I figured out from my old Calc2 notes that it was a harmonic series, but then I had to look up how to sum it. I also had to look up the best way to get two decimal places that are rounded correctly. I have a feeling in the real world having to Google things is pretty common, but I suppose I would have been stuck if I got this as an interview question.
Nice work! I didn't think to just have the while loop go as long as the digit is greater than 9. That's a good way to have it stop when you've reached a single digit sum. I also like how you just used n for everything. I made some new variables that I now realize weren't needed.
And here I was so proud of my 18 line solution on this, my very first Kata... haha