## Trending News

Promoted

# i want a program from 1 to 100 prime numbers?

### 1 Answer

Relevance

- 1 decade agoFavorite Answer
Hay here goes your code:

//comment to make you more clear..

limit = 100; // arbitrary search limit

for (i = 2; i <= limit; i++) {

is_prime[i] = true // assume all numbers are prime at first

}

for (n = 2; n <= sqrt (limit); n++) {

if (is_prime[n]) {

// eliminate multiples of each prime, starting with its square

for (i = n^2; i <= limit; i += n) { is_prime[i] = false }

}

}

for (n = 2; n =< limit; n++) {

if is_prime[n] then print n

}

Its algorithm for prime number modify as per ur programing language

goog luck

Still have questions? Get your answers by asking now.