Pattern recognition

I am a novice Julia user and investigating its capabilities. Is it capable of pattern recognition? Here’s an example:
For E(n)=n^2 -n + p, p=41, p <=n <2p;
There exists a mixture of primes and composites. The composites form a pattern. Can Julia detect it?

Summary
(p+k^2)^2 -k^2 =  (p+k^2+k)(p+k^2-k)

Are you asking about compiler optimization? I think it’s a little unclear what you mean, maybe some clarification would help get a good answer.

1 Like

Julia can put you on the right track to finding the pattern. But the rest is up to you, I think

julia> for  n in p:2p-1
           X=n^2 -n + p
           isprime(X) &&continue
           show((n-p, factor(Vector, X)))
           println()
       end
(0, [41, 41])
(1, [41, 43])
(4, [43, 47])
(9, [47, 53])
(16, [53, 61])
(25, [61, 71])
(36, [71, 83])
1 Like