A C++ interview question

Write a C++/C function which prints out prime integers, i.e., given an input X, print out all its prime numbers. For example,

if X=20, prime elements will be: 1, 2, 3, 5, 7, 9, 11, 13, 17, 19.
If X= 100, primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.


void (int X)
{
???????
???????
}


Thanks.

登录后才可评论.