Last active
December 26, 2015 19:29
-
-
Save joeyv/7201136 to your computer and use it in GitHub Desktop.
IM STUCK
This file contains 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 characters
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"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lol this code is so bad