I made some #Java-y pseudocode for the loop in the #DoctorWho episode "Heaven Sent" from last season. For fun.
Recursive: https://mastodon.bigdinosaur.org/@jbbdude/55004
For loop: https://mastodon.bigdinosaur.org/@jbbdude/55120
Pretty sure they're buggy and wrong, especially the for loop version because counting.
Enjoy, nerds. Feel free to criticize and/or correct because pedantry.
Number of loops = 4.5 billion years (from ep dialogue) / 3 day loop length (estimate from https://j.mp/dwhslen)