Problem 52567. Easy Sequences 7: Easy as Composite Pi

The prime Pi function is defined as the number of prime numbers from 1 to a certain given limit. In MATLAB, it is easy to create a prime Pi procedure, because there are built-in functions such as "primes" and "isprime". To calculate the prime Pi up to 100, we may just proceed as follows:
>> numel(primes(100))
>> ans =
>> nnz(isprime(1:100))
>> ans =
Can we make a function for "composite Pi", which is the number of composite numbers from 1 to a given limit, inclusive? Let's find out...
NOTE: The number '1' is considered as neither prime nor composite.

Solution Stats

37.5% Correct | 62.5% Incorrect
Last Solution submitted on Nov 23, 2022

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author116

Community Treasure Hunt

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

Start Hunting!