I have no idea what the above fuction even SHOULD do, and I don't want to know, becouse of 3 reasons:
1) no code tags
2) you are TOTALY overcompilcating too much more than a lot!
3) the function does some strange things, and it never returns
The function shall return a bool and have a for loop from 2 to sqrt(n), in which you check the modulo of n and the current iteration number: if it's zero, return false. At the end of the function, outside of the for loop, you return true. It's that simple. As I already said, I dont'k know and don't care what you wrote in your function becouse it's ridicuolous!
Sorry for bad code,I just dont know what to do when i get all the numbers that are factors of some number,I mean I dont know how to from that sequence extract prime ones.Thats all,but anyway thanks!