• + 0 comments
    T=[1,1,1,1,2]
    P=[2,3,5,7,11,13]
    def NP(N):
        global P
        if P[-1]<=N:
            for n in range(P[-1]+2,N+1,2):
                isP=True
                i=1
                while P[i]**2<=n:
                    if n%P[i]==0:
                        isP=False
                        break
                    i+=1
                if isP :
                    P.append(n)
            return len(P)
        for i in range(len(P)):
            if P[i]>N:
                return i
                
    def redJohn(n):
        global T
        for _ in range(n+1-len(T)):
            T.append(T[-1]+T[-4])
        return NP(T[n])