# Thread: need 2 factors to get as close to 32767 as possible

1. ## need 2 factors to get as close to 32767 as possible

i need 2 factors between 20 and 250 that gets as close to 32767 (but not above this value
the biggest i can come up with is 181x181 = 32761

how ever i really wish to get close to around a 2:3 or 3:4 ratio (approximate) on the factors  Reply With Quote

2. write a program?  Reply With Quote

3. Code:
```int tmp_i = 0;
int tmp_j = 0;

int min_a = 20;
int max_a = 250;
int min_b = 20;
int max_b = 250;

int sol = 32767;

for(int i = min_a; i <= max_a; i++){
for(int j = min_b; j <= max_b; j++){
if(i*j <= sol){
if(i*j > tmp_i*tmp_j){
tmp_i = i;
tmp_j = j;
System.out.println(i+" * "+j+" = "+i*j);
}
}else{
break;
}
}
}```  Reply With Quote

4. 32767=7*31*151=217*151  Reply With Quote

5.   Reply With Quote

6. Originally Posted by Jean-Marie Barone 32767=7*31*151=217*151
Doh i didn't think of looking at the prime factors, but thank you. this is perfect.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•