Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Uebung05_A4 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = 0, k = 0;
- n = sc.nextInt();
- boolean Primzahl = true;
- for ( k = 2; k < (n-1) && Primzahl; k++ ) {
- if (( n % k ) == 0 ) {
- Primzahl = false;
- }
- }
- if ( Primzahl ) {
- System.out.print("Diese Zahl ist eine Primzahl");
- } else System.out.println("Diese Zahl hat " + (k-1) + " als kleinsten Teiler");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement