Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Primes
Description A pretty straight forward task, calculate the number of primes between 2 integers.
Given 2 integers A ≤ B < 105 what’s the number of primes in range from A to B inclusive. Note: A prime number is a positive integer greater than 1 and is divisible by 1 and itself only. For N to be prime it is enough to test the divisibility of numbers less than or equal to square root of N. Input As many as 1000 lines, each line contains 2 integers A and B separated by a space. Input is terminated when A = B = -1 (Do not process this line). Output For every line in input – except for the last line where A = B = -1 - print the number of prime numbers between A and B inclusive. Sample Input 0 9999 1 5 -1 -1 Sample Output 1229 3 Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator