I was finding out highest prime factor which divides num, as shown in program, there\'s a issue with array and
arr[j] = i;
j++;
Excepti
It looks like you are finding all divisors of num; one of these will be the largest prime factor. Two related facts alone should help make the problem tractable for smallish numbers:
1. If d is a divisor, then so is num/d.
2. you needn't check for any divisors greater than the sqrt(num).
To keep track of divisors, use a Set object.