Print Prime Numbers from 1 to N | Sieve of Eratosthenes

Write a program to print prime numbers from 1 to N (where n is an integer).

This problem can also be asked like,

i) How to print prime numbers from 1 to 100.

ii) How to print prime numbers from 1 to 1000 etc.

In this tutorial, we are going to learn how to print prime numbers efficiently using sieve algorithm.

Suppose the value of N is 10, So the prime numbers between 1 to 10 is 2, 3, 5, 7.

Before writing a code, let’s first first understand, what is prime number?

Singleton Design Pattern in PHP

In this tutorial, I am going to discuss what is singleton design pattern, Why and when to use singleton design pattern in php.

What is Singleton Design Pattern?

In Singleton Design Pattern, we ensure a class has only one and only one instance and that instance can be accessed globally. The Singleton design pattern restricts the instantiation of a class to one object.

How to Create Singleton Class in PHP