Rakuten Kobo interview question

A maths question which ended up being a recursive function.