This is not stackoverflow.com. But if you had looked there, you would have found a half dozen solutions in various programming languages.. Hope you didn’t spend 2 weeks trying to avoid doing a 31 element loop. That’ll take some CPU time to recoup. :)
I did! (in a way) haha...it's ok. Lesson learned: work on a personal computer (or VM) one has admin rights to! Yes yes...
(side note: stackoverflow.com is blocked on my work computer...dang firewall rules....grumble...). Thanks for the friendly flame!