Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Uebung05_A4 {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. int n = 0, k = 0;
  8. n = sc.nextInt();
  9. boolean Primzahl = true;
  10.  
  11.  
  12. for ( k = 2; k < (n-1) && Primzahl; k++ ) {
  13. if (( n % k ) == 0 ) {
  14. Primzahl = false;
  15. }
  16.  
  17. }
  18.  
  19.  
  20. if ( Primzahl ) {
  21. System.out.print("Diese Zahl ist eine Primzahl");
  22. } else System.out.println("Diese Zahl hat " + (k-1) + " als kleinsten Teiler");
  23.  
  24.  
  25.  
  26.  
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement