Help:=proc(): print(`CF(a), CF1(a,K), IsPeriodic(L,p)`): end: #CF(a): inputs a positive rational number and outputs #the list of terms in the (simple)-continued fraction CF:=proc(a) local b,c,L1: if a<0 or not type (a,rational) then ERROR(`We are followers of Pythagors`): fi: if type(a,integer) then RETURN([a]): fi: b:=trunc(a): c:=1/(a-b): L1:=CF(c): [b,op(L1)]: end: Digits:=100: #CF1(a,K): inputs a positive real number and a positive #integer K, outputs #the list of first K terms in the (simple)-continued fraction of a CF1:=proc(a,K) local L,b,a1: a1:=evalf(a): b:=trunc(a1): if K=1 then RETURN([b]): fi: a1:=1/(a1-b): L:=CF1(a1,K-1): [b, op(L)]: end: #IsPeriodicP(L,p): inputs a list L and a pos. integer p #and outputs true if L is periodic of period p #starting at the beginning IsPeriodicP:=proc(L,p) local i: for i from 1 to nops(L)-p do if L[i]<>L[i+p] then RETURN(false): fi: od: true: end: