Flag why we used here?

what is the function of flag ?

why we use it boolean flag ?

@simar4303_9715cda6958f0652 flag is just a boolean variable which is used to store whether the No. is prime or not Whenever in the loop if number gets divided that means no. is not prime so we make flag = false(not prime) and since initially flag was true if for the whole for loop if no. is not divisible then it is prime and the flag remains true(Prime).