You are likely looking for the search term “modulus”.
For example, you could have a property called HowManyTimesIDidSomething
When your functions runs that says you did something, you could increment your property like so:
HowManyTimesIDidSomething++;
Then after doing this you could check how much remains if you divide it by 5 (modulus)
If(HowManyTimesIDidSomething % 5 == 0){
// Do something every time the property is divisible by 5
}
Hope that helps! Good luck dude!