Usage of flag in the question

At 6:37, we have used flag. How is it helping in checking whether a number is prime or not? why is it necessary…if we simply add some print prime and not prime commands like we have done in previous questions, won’t it be enough for differentiating between prime and non prime ones?

hi @sbhardwaj1be21_2a991b329433c059 suppose there is a no say 15 it is div by 3 and 5 so it will print 2 times not prime so its better to turn off the flag and after the loop check if flag is 1 or 0

1 Like