Quantcast
Channel: C
Viewing all articles
Browse latest Browse all 46

How many prime numbers are there in this sequence

$
0
0
I'm writing a program to calculate the number of prime numbers in a sequence. There's a variable called num that is given and then the program must calculate how many prime numbers there are from 2 (the smallest prime number) to num.

It should be something like that:

Enter a number greater than 1: 7 There are 4 prime numbers between 2 and 7.

This is because 2,3,5 and 7 are prime numbers, a total of 4 numbers.

The code below shows the variable num which is equal to 7, the main function...

How many prime numbers are there in this sequence

Viewing all articles
Browse latest Browse all 46

Latest Images

Trending Articles



Latest Images