Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class optimusprime {
- public static void main(String[] args) {
- System.out.print(" Prime Numbers"); // table head
- int n = 100;
- for(int i = 2; i <= n; i++) { // lines 12 -22 sets up the logic for prime numbers
- int count = 0;
- for(int j = 2;j < i;j++) {
- if (i % j == 0) {
- count++;
- }
- }
- if(count==0) {
- System.out.print(" ");
- System.out.print( " | "); // lines 25-30 was my poor attempt at creating a table
- if (i % 10==0)
- System.out.print("\n");
- System.out.print(i + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement