Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 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;
  8. n = sc.nextInt();
  9. boolean Primzahl = true;
  10.  
  11. for ( int k = 2; k < (n-1) && Primzahl; k++ ) {
  12. if (( n % k ) == 0 ) {
  13. Primzahl = false;
  14. }
  15.  
  16.  
  17. }
  18. if ( Primzahl ) {
  19. System.out.print("Diese Zahl ist eine Primzahl");
  20. }
  21.  
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement