Solve an equation involving primes and fractions - MATLAB Cody - MATLAB Central

Problem 57477. Solve an equation involving primes and fractions

Difficulty:Rate
Write a function to find pairs of primes p and q satisfying the equation
p/(p+1) + (q+1)/q = 2n/(n+2)
where n is an integer. The function should take a number x as input and produce the triples p, q, and n such that p <= x. If there are no solutions, the function should return three empty vectors.
This problem is adapted from one in the 2012 European Girls’ Math Olympiad.

Solution Stats

91.67% Correct | 8.33% Incorrect
Last Solution submitted on Mar 09, 2025

Problem Comments

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

Problem Recent Solvers7

Community Treasure Hunt

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

Start Hunting!