Consecutive Number After 16 in iOS

i have this code in if statement , and i think it is very big , how can i change this by short code and for infinity i.e that i want the if statement to work on two and after two by sixteen i.e 2 += 16 , forever , i know that my question might be not understandable

• Swift Playground and Simulator Error (ipc/mig) server died, Unable to boot the iOS Simulator
• How to change the name of an iOS app?
• Enterprise app deployment doesn't install on iOS 8.1.3
• How do you select uitableview rows programmatically
• Admob pods do not work after firebase integration
• How to center a label horizontally for all iOS devices in Swift
• 4 Solutions Collect From Internet About “Consecutive Number After 16 in iOS”

This can be reduced to a mathematical problem. What you want is to divide by 16 and see if there is no ‘remainder’. The ‘modulo’ operator gives you this remainder. You can Google it if you want to understand. So, as others have quickly posted before me, modulo in Objective-C is done via %. So `x % 16` means: divide x by 16 and return the remainder (or: subtract 16 from x until x is smaller than 16). `x % 16` will be a number between 0 and 15. Always. When `x % 16` is 0, it means x is dividable by 16.

Since you want to take action when count is 2 + 16 * n, you want to subtract 2 from count first. Like so `if ( ( count - 2 ) % 16 == 0)`. Or you can do this, which is shorter but perhaps less easy to understand: `if ( count % 16 == 2 )`.

Take the current count and subtract 2. If the number is divisible by 16 (the remainder when you do modulo division is zero), then your statement is true.

``````if ((count - 2) % 16 == 0)
{
_secondBall.hidden = YES;
}
``````

Try this:

`if ((count - 2) % 16 == 0)`

Use this syntax

``````if ((count-2) % 16 == 0)
``````