Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public int hashCode(){
- final int p1 = 3;
- final int p2 = 7;
- final int p3 = 11;
- final int p4 = 17;
- final int p5 = 19;
- final int p6 = 23;
- int result = 0;
- for(int i = 0; i < DIM; i++){
- int temp = 1;
- for(int j = 0; j < DIM; j++){
- switch(j)
- {
- case 0:
- temp += (tabla[i][j] + 2) * p4;
- break;
- case 1:
- temp += (tabla[i][j] + 2) * p5;
- break;
- case 2:
- temp += (tabla[i][j] + 2) * p6;
- break;
- }
- //temp += tabla[i][j] + 2;
- }
- switch(i)
- {
- case 0:
- result += temp * p1;
- break;
- case 1:
- result += temp * p2;
- break;
- case 2:
- result += temp * p3;
- break;
- }
- }
- return result;
- }
- private boolean isPrime(int n) {
- for(int i = 2; i < n ; i++) {
- if(n % i == 0) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement