[Original reprint annotated Source]
Title 2: Determine how many primes are in between 101-200, and output all primes.
Ideas:
Prime (prime number) is the addition of 1 and itself, no other numbers can be divisible by it
Java Code Implementation:
1 PackageJichu;2 3 Public classJICHU24 {5 Public Static voidMain (string[] args)6 {7 //For Loop traversal 101-2008 for(inti = 101; I < 200; i++)9 {Ten Booleanb =false; One A //Inner Loop to determine if I is a prime number - for(intj = 2; J <= I-1; J + +) - { the - //except for 1 and itself, if I can divide the other numbers by B = False - if(i% j = 0 ) - { +b =false; - Break; + } A at //B = True if not divisible - Else - { -b =true; - } - } in - //if B = true, print out to if(b = =true) + { - System.out.println (i); the } * } $ }Panax Notoginseng}
[Original reprint annotated Source]
Java algorithm question 2. Determine how many primes are in between 101-200, and output all primes.