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
Who Deserves Your Praise? Discover the New Contribution Widget!
...
We are excited to announce another update to our Discussions area: the...

Problem Recent Solvers7

Suggested Problems

More from this Author292

Community Treasure Hunt

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

Start Hunting!
Go to top of page