[ create a new paste ] login | about

Link: http://codepad.org/kWm954G8    [ raw code | output | fork ]

C++, pasted on Jul 4:
//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; 
                } 
    }  


Output:
1
Line 22: error: use of C99 long long integer constant


Create a new paste based on this one


Comments: