'Greatest_subsequential_sum N= 20 'number of elements randomize 0.52 for K = 1 to 5 a$ = using("##",int(rnd(1)*12)-5) for i=2 to N a$ = a$ +","+using("##",int(rnd(1)*12)-5) next call maxsumseq a$ next K sub maxsumseq a$ sum=0 maxsum=0 sumStart=1 end1 =0 start1 =1 token$="*" i=0 while 1 i=i+1 token$=word$(a$, i, ",") if token$ ="" then exit while 'end of stream x=val(token$) sum=sum+x if maxsum0 then print "Maximum sum subsequense: ";start1 ;" to "; end1 else print "Maximum sum subsequense: is empty" end if print "Maximum sum ";maxsum print end sub