Problem Link: http://www.spoj.com/problems/PRIME1/
Logic:
No composite number less than or equal to will have a factor greater than , so we only need to know all primes up to this limit, which is no greater than 31622 (square root of 109).
To view my solution:
https://github.com/shivam04/spoj/blob/master/PRIME1.cpp
SUMMARY
Given an interval where and , find all prime numbers in that interval.Logic:
No composite number less than or equal to will have a factor greater than , so we only need to know all primes up to this limit, which is no greater than 31622 (square root of 109).
To view my solution:
https://github.com/shivam04/spoj/blob/master/PRIME1.cpp
No comments:
Post a Comment