periods=[]; for power=4:6 total_n=400; power_col=[]; for n=1:total_n np=n^power; power_col=[power_col; np]; end fdiff_col=[]; for m=1:total_n-1 fdiff=power_col(m+1)-power_col(m); fdiff_col=[fdiff_col; fdiff]; end sdiff_col=[]; for p=1:total_n-2 sdiff=fdiff_col(p+1)-fdiff_col(p); sdiff_col=[sdiff_col; sdiff]; end iscp=[]; for r=1:total_n-2 x=[fdiff_col(r), sdiff_col(r)]; iscp = [iscp; iscoprime(x)]; end period=0; total=length(iscp); found=0; for per=2:floor(total/2) rep=floor(total/per); per_M=[]; for v=1:rep per_c=iscp(per*(v-1)+1:per*v); per_M=[per_M, per_c]; end allRowsEqual=0; c=0; for d=2:size(per_M, 2) if sum(per_M(:, d)==per_M(:, 1))/size(per_M, 1)==1 c=c+1; end end if c==size(per_M, 2)-1 period=per; accuracy=c+1; break end end periods=[periods; period]; end periods