Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class liczbypierwsze {
- static int NWD(int a, int b)
- {
- int c;
- while (b != 0)
- {
- c = a % b;
- a = b;
- b = c;
- }
- return a;
- }
- public static void main(String[] args) {
- System.out.println("Podaj pierwsza liczbe: ");
- Scanner odczyt = new Scanner(System.in);
- int a = odczyt.nextInt();
- System.out.println("Podaj druga liczbe: ");
- int b = odczyt.nextInt();
- if ( a >= 1000000 || b >=1000000 && a <= 1 || b <= 1 )
- {
- System.out.println("Podales za duze liczy!");
- }
- else
- {
- System.out.println("NWD to: "+ NWD(a,b));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment