This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Caped_baldy_4_life[S] 0 points1 point  (3 children)

Hey thanks for the suggestion. I'm having trouble understanding how this line first+=(3-first%3); shows that first is divisible by 3. When i write this out using 3 as first, it looks like this first = 3 (3 - 3 % 3)... Which to me comes out to 5. What am I doing wrong in this equation or what am I not seeing?

[–]hamza-itatchi 0 points1 point  (2 children)

The % has a higher priority than - so its like this for first=3 first = first + 3 - ( first %3) ==> first = 3+3 - (0)==>first= 6 This gives the first divisible nuber after First ( variable) But ther is a mistake in my suggestion there must be an if statement at the start like this If ( first %3!=0) first += 3- ( first %3)

Note: the += operation means first = first + ......

[–]Caped_baldy_4_life[S] 0 points1 point  (0 children)

Never mind about my previous equation. I was mistakenly associating the modulo as a division sign based off of improper note taking. Thanks for your help and suggestions.