Problem 44861. Ratio between sums of prime and non-prime numbers

Write a function that calculates the ratio between the sum of the prime numbers less than or equal to x, and the sum of the non-prime numbers up to the greatest prime less than or equal to x.
For example, if x = 7, then:
sum_prime = sum([2 3 5 7]) = 17
sum_non_prime = sum([1 4 6]) = 11
Therefore, the desired ratio is:
prime_ratio = sum_prime / sum_non_prime = 17 / 11

Solution Stats

38.46% Correct | 61.54% Incorrect
Last Solution submitted on Apr 07, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers35

Suggested Problems

More from this Author11

Problem Tags

Community Treasure Hunt

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

Start Hunting!