integer function period8(n, aa, i)
implicit real(8) (a-h, o-z)
real(8) aa(0:n)

period8 =0
do i =n-1, 0, -1
if(aa(n) ==aa(i)) then
period8 =n-i
exit
endif
enddo

END function period8
