c white15.f c Jan 15 2009 Reads in a sequence and extends it by repeatedly appending c the curling number. c Related to Gijswijt's sequence A090822 and more directly to A094004. c Used to produce A116909 by giving it an input file containg the two lines c 22 500 c 2322322323222323223223 c See notebook Latt 94 p 97 c implicit integer(a-z) integer a(100000) c read length of starting sequence and number of terms needed read(*,*)M0,M1 c read initial sequence read(*,200)(a(i),i=1,M0) 200 format(60i1) write(*,*)"Start" write(*,*)"M0, M1 = ",M0,M1 write(*,200)(a(i),i=1,M0) 100 format(30i2) c get next term do 1 n=M0+1,M1 c write(*,*)"Next n = ",n krec=1 yrec=1 c try next value of ly = length of y do 2 ly=1,n-1 if((krec+1)*ly.gt.n-1)goto 7 c write(*,*)" trying ly = ",ly c compute the k for this ly do 3 k=2,M1 do 4 i=1,ly what=n-(k-1)*ly-i if(a(what).ne.a(n-i))goto 5 4 continue c got to the end of that matching row 3 continue c will never get here write(*,*)"ERROR #3" stop 5 continue k=k-1 c write(*,*)"k = ",k if(k.le.krec)goto 6 c new record for k krec=k yrec=ly c write(*,*)" increased k to ",krec c write(*,*)" with ly = ",ly 6 continue 2 continue 7 continue c exit if krec = 1 c if(krec.eq.1)goto 299 a(n)=krec 1 continue write(*,100)(a(i),i=1,M1) do 30 n=1,500 30 write(*,31)n,a(n) 31 format(i6,i4) stop end