You should check out a proper authority such as Randall Monroe.
The problem with doubling anything is that the more you fold it, the harder it gets to fold it next time.
However, there's no need to write fancy algorithms to compute. Since you're doing a binary fold, to reach the moon, you just need to compute t*2^n, where "t" is the thickness of one sheet of paper, solving for n and assuming absolutely no space between layers.
Conversely, the horizontal dimensions would be the original paper size proportional to division by 2^n assuming you fold in an aspect-preserving way and assuming that the fold point has no dimension of its own (though in actuality, the fold point would be as wide as the folded paper is thick).