Last active
December 26, 2015 19:29
Revisions
-
joeyv revised this gist
Oct 29, 2013 . 1 changed file with 28 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 = 0; int num,num2, i; Scanner scan = new Scanner(System.in); num = scan.nextInt(); 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; if (total == 0){ System.out.println ("\nNot Prime"); break; } else { continue; } } if (total >= 1){ System.out.println ("\nPrime"); } } } -
joeyv created this gist
Oct 28, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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); } } }