Let
a=BC0, b=AC0, and
c=AB. The altitude gives
C0C1=cab, and
△C0C1B∼△AC0B with ratio
ca. Each later altitude repeats this construction in a triangle scaled by
ca, so the segments
Cn−1Cn form a geometric series and
n=1∑∞Cn−1Cn=1−cacab=c−aab=6p=6(a+b+c).
Since
b2=c2−a2=(c−a)(c+a), we get
(c−a)⋅(a+b+c)=(c−a)(c+a)+(c−a)b=b(b+c−a), so
ab=6b(b+c−a), that is
7a=6b+6c. Squaring
6c=7a−6b and using
36c2=36a2+36b2 gives
36a2=49a2−84ab, hence
13a=84b.
Because the side lengths are pairwise relatively prime,
a=84 and
b=13, so
c=67⋅84−6⋅13=85, and indeed
132+842=852. Then
p=84+13+85=182 (and
c−aab=184⋅13=1092=6p checks).