December 23, 2018
Find the first k primes
Threads: Enter a positive integer k, prints a list of the first k primes.
Input: An integer k.
Output: A line consists of the first k primes. The numbers separated by spaces.
For example:
input: 2 output: 2 3
You are not logged in? Log in to Submit Now!
12 Comments
Add a Comment
You must be logged in to post a comment.
Hey Admin, Find the first k prime numbers, please watch it again.
Test Input:
100
Test Output:
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 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541
Your Output:
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 101 103 1
07 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 2
23 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 3
37 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 4
57 461 463 467 479 487 491 499 503 509 521 523 541
How does it do you??
Oh, after an afternoon of bug hunting, I found out that your output contains extra characters 'n' (down the line). You should remove the crt library and it will be over.
Admin, look at the test again when I run it, my number is correct but it says wrong
Which test are you??
test input 100
rank 5 that
Oh, after an afternoon of bug hunting, I found that your output contains extra characters 'n’ (down the line). You should remove the crt library and it will be over.
tks ad
Toan” running… “C'mon admin :((
Every day only 100 submit for everyone. The amount of submissions is limited.
#include
int main(){
int k, i=0;
int a=1, c=0, b;
scanf(“%d”, &k);
while(c!=k){
a++;
b=0;
i=0;
while(i<=a){
i++;
if(a%i==0){
b+=1;
}
}
if(b==2) {
printf("%d ", a);
c+=1;
}
}
}
very good