Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class zad3 {
- public static int min(int a,int b){
- if (a<b) return a;
- else return b;
- }
- public static boolean czyPierwsza(int a){
- if(a<2) return false;
- for(int i=2;i<a;i++)
- if(a%i==0)
- return false;
- return true;
- }
- public static int[] pierwsze(int tab1[], int tab2[]){
- int it = min(tab1.length,tab2.length);
- int rozm = 0;
- for(int i=0;i<it;i++)
- {
- if(czyPierwsza(tab1[i]) && tab1[i]<tab2[i])
- rozm++;
- }
- int t3[] = new int[rozm];
- int licznik=0;
- for(int i=0;i<it;i++)
- {
- if(czyPierwsza(tab1[i]) && tab1[i]<tab2[i])
- {
- t3[licznik]=tab1[i];
- licznik++;
- }
- }
- return t3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement