we can also use this way as give below this way we can reduce 50% looping step while(divisor <= n/2){ //code }