Computer Science, asked by radiantroja, 4 months ago

write a program that takes L and R as input and displays the number of prime numbers that lie between L and R (L and R inclusive) and can be represented as sum of two consecutive prime numbers +1

Answers

Answered by saransrini03
1

from math import sqrt;

N = 100005;

# To check if a number is prime or not

isprime = [True] * N;

# To store possible numbers

can = [False] * N;

# Function to return all prime numbers

def SieveOfEratosthenes() :

   for p in range(2, int(sqrt(N)) + 1) :

       # If prime[p] is not changed,

       # then it is a prime

       if (isprime[p] == True) :

           # Update all multiples of p greater

           # than or equal to the square of it

           # numbers which are multiple of p and are

           # less than p^2 are already been marked.

           for i in range(p * p, N , p) :

               isprime[i] = Fals

Similar questions