Skip to content

Instantly share code, notes, and snippets.

@joeyv
Last active December 26, 2015 19:29
Show Gist options
  • Save joeyv/7201136 to your computer and use it in GitHub Desktop.
Save joeyv/7201136 to your computer and use it in GitHub Desktop.
IM STUCK
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");
}
}
}
@imryan
Copy link

imryan commented Oct 30, 2013

Lol this code is so bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment