Tally the Divisible Slots

Basic

A scheduling report needs to know how many slot numbers from 1 to n are divisible by either 3 or 5, the two cadence intervals the team uses.

Implement `solve(Integer n)` to return how many integers from 1 to `n` (inclusive) are divisible by 3 or by 5.

Examples

Inputn = 15
Output7
Inputn = 5
Output2
Hints
  • Loop 1..n; count when Math.mod(i,3)==0 OR Math.mod(i,5)==0.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.