Prime visits doubt

This question was explained in one video. I tried but I dont know why test arnt working. please check

hello @mittali

dont compute prime again n again.
instead call only once and store the results in array.
and then use that array to answer each array efficiently.

I think I cant use extra space in this question. or can i?

u can…

checkout the video that i shared in my last response