#include <iostream>
#include<cmath>
using namespace std;
int main()
{ cout << "Prime Numbers between 1 and 100 are:
";
for(int i=2;i<=100;++i) //loop to check for each number in the range
{ int ctr=0; //to maintain factor count
for(int j=2;j<=sqrt(i);++j) //checking for factors
{ if(i%j==0)
ctr=1; //increasing factor count when found
}
if(ctr==0) //checking and printing prime numbers
cout<<i<<" ";
}
return 0;
}
// C++ program to display Prime numbers till N
#include <bits/stdc++.h>
using namespace std;
//function to check if a given number is prime
bool isPrime(int n){
//since 0 and 1 is not prime return false.
if(n==1||n==0) return false;
//Run a loop from 2 to n-1
for(int i=2; i<n; i++){
// if the number is divisible by i, then n is not a prime number.
if(n%i==0) return false;
}
//otherwise, n is prime number.
return true;
}
// Driver code
int main()
{
int N = 100;
//check for every number from 1 to N
for(int i=1; i<=N; i++){
//check if current number is prime
if(isPrime(i)) {
cout << i << " ";
}
}
return 0;
}