List primes of the form xy+z - MATLAB Cody - MATLAB Central

Problem 60581. List primes of the form xy+z

Difficulty:Rate
Consider three consecutive integers x, y = x+1, and z = x+2. When is the number xy+z prime? For example, if x = 3 or x = 5, then the results are 17 and 37, both prime, but if x = 7 or x = 11, the results are 65 and 145, which are composite.
Write a function to list prime numbers less than or equal to the input that can be written in the form . The function should also return the values of x (i.e., the smallest number of the triple) leading to the primes.
Optional: Prove that the number of primes of this form is infinite.

Solution Stats

64.71% Correct | 35.29% Incorrect
Last Solution submitted on Jan 13, 2025

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

YouTube-inspired Image
YouTube-inspired
  • 15 Problems
  • 2 Finishers

Problem Recent Solvers9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!