[C language Ta] All prime numbers of less than 1000

Source: Internet
Author: User
# Include <stdio. h> # include <stdlib. h> # include <math. h> int isprime (int x) {If (x <= 0) {return 0;} else if (x = 1 | x = 2) {return 1 ;} else {int I; for (I = 2; I <X; I ++) {If (X % I = 0) {break ;}} if (I = x) {return 1;} else {return 0 ;}} void main () {int COUNT = 0; printf ("############ all prime numbers in less than 1000 ############## \ n "); for (INT I = 1; I <1000; I ++) {If (isprime (I) {printf ("% 6D", I); count ++; if (count % 8 = 0) {printf ("\ n") ;}} printf ("\ n ");}

 

 

############ All prime numbers within 1000 ##############
1 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
131 137 139 149 151 157 163
173 179 181 191 193 197 199
223 227 229 233 239 241 251
263 269 271 277 281 283 293
311 313 317 331 337 347 349
359 367 373 379 383 389 397
409 419 421 431 433 439 443
457 461 463 467 479 487 491
503 509 521 523 541 547 557
569 571 577 587 593 599 601
613 617 619 631 641 643 647
659 661 673 677 683 691 701
719 727 733 739 743 751 757
769 773 787 797 809 811 821
827 829 839 853 857 859 863
881 883 887 907 911 919 929
941 947 953 967 971 977 983
997
Press any key to continue...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.