//Program for generating no divisible by all no between 1 & n
#include<iostream>
#include<cstdlib>
using namespace std;
long sieve[100000000],primes[5000000];
void primegen(long);
int main(void)
{
long no,i,j;
double LCM=1;
system("cls");
//inputting the no..
cout<<"\n\tEnter the no..: ";
cin>>no;
primegen(no);
//checking for highest possible power of a particular prime
for(i=0;primes[i]!=0;i++)
{
for(j=primes[i]; ;j*=primes[i])
if(j>no)
break;
LCM*=(1LL*j/primes[i]);
}
//displaying op
cout<<"\n\nRequired no. is : "<<LCM<<"\n\n\n";
system("pause");
}
//fn for generating prime nos..
void primegen(long n)
{
long i,j,sq,k=0;
for(i=2;i<=n;++i)
if(!sieve[i]) //proceed only if no. is not already marked
{
primes[k++]=i; //store the prime no.
for(j=i*i;j<=n;j+=i) //mark all multiples of a prime
sieve[j]=1;
}
}