Skip to content

Instantly share code, notes, and snippets.

@joeyv
Last active December 26, 2015 19:29

Revisions

  1. joeyv revised this gist Oct 29, 2013. 1 changed file with 28 additions and 8 deletions.
    36 changes: 28 additions & 8 deletions Prime.java
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,41 @@
    import java.util.Scanner;
    public class Prime{

    public static void main(String []args){
    int total;
    int num, i;
    int total = 0;
    int num,num2, i;

    Scanner scan = new Scanner(System.in);

    num = scan.nextInt();

    for( i = num; i >= 1; i-- ){

    num2 = num - 1;

    //Checking if user imputs 1 or 2
    if (num == 1){
    System.out.println ("\nNot Prime");
    }
    if (num == 2){
    System.out.println ("\nPrime");
    }


    for( i = num2; i >= 2; i-- ){

    total = num % i;
    System.out.println (total);


    if (total == 0){
    System.out.println ("\nNot Prime");
    break;
    } else {
    continue;
    }
    }

    if (total >= 1){
    System.out.println ("\nPrime");
    }



    }
    }
  2. joeyv created this gist Oct 28, 2013.
    21 changes: 21 additions & 0 deletions Prime.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import java.util.Scanner;
    public class Prime{

    public static void main(String []args){
    int total;
    int num, i;

    Scanner scan = new Scanner(System.in);

    num = scan.nextInt();

    for( i = num; i >= 1; i-- ){

    total = num % i;
    System.out.println (total);


    }

    }
    }