Question: please note i need within what we have coverd so ( basic c )(if statement)(if else )(switch)(while and for loop ) ( nested loop )


please note i need within what we have coverd so ( basic c )(if statement)(if else )(switch)(while and for loop ) ( nested loop ) (do while loop )
uestion 02: [Counting Primes Problem statement Write a C program to count the prime numbers that are less than or equal to a given integer, z. Background A positive integer, p-2, is said to be prime if and only if p is divisible only by itself and by 1. For example, the integer 7 is a prime number, because 2, 3, 4, 5, and 6 do not divide 7. On the other hand, the integer 6 is not prime because it is divisible by 2 and 3 (in addition to 1 and itself). Integers that are not prime numbers are called composite numbers. The fundamental theorem of Number Theory states that any nonzero integer n can be represented as a product of some prime factors. For example, 6 is composite and it can be represented by 2*3. Here, the integers 2 and 3 are referred to as the prime factors of the composite integer 6. Here is the easiest way to test if an integer n is a prime number or not. For every m in the set M-12, 3, 4, sqrt(n), we check if the remainder n%m equals 0. If this happens to any m in M, then the number is not prime (composite). Otherwise, the number is prime. Note that we do not have to go all the way to n- 1 for primality testing since it is well known that every composite number has a prime factor less than or equal to its square root. Finding one prime factor of n, call it p, is enough to conclude that n is a composite number, given that p
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
