List the good primes - MATLAB Cody - MATLAB Central

Problem 49783. List the good primes

Difficulty:Rate
The mth prime p_m is classified as “good” if p_m^2 > p_{m-k}p_{m+k} for 1 <= k <= m-1. For example, 5 is a good prime because 5^2 = 25 is greater than 2x11 = 22 and 3x7 = 21, but 7 is not because 7^2 < 5x11.
Write a function to list the first n good primes.

Solution Stats

31.91% Correct | 68.09% Incorrect
Last Solution submitted on Sep 11, 2024

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
18
6

Problem Recent Solvers14

Suggested Problems

More from this Author291

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page