program PNinfinite
! Identification of the leading pairwise-nonrecurrant INFINITE sequence, by Thomas Bewley.
integer :: a(1:10000),pairs(1000,10000),flag,s,j,k,n=10000
a(1:n)=1; do; pairs=0          ! Sweep to detect & disregard sequences with repeated pairs
  l1: do j=2,n; flag=1; do k=1,j-1; if (a(k)==a(j)) then; s=j-k;
    if (pairs(a(k),s)==0) then; pairs(a(k),s)=1; else; a(j)=a(j)+1; flag=0; exit l1; end if
  end if; end do; end do l1
  if (flag==1) exit
end do
print *, 'a=',a(1:n)-1,', flag=',flag
end program PNinfinite