Advertisement
Nikolaiko

[Swift] Multiples of 3 or 5

Jan 23rd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.18 KB | None | 0 0
  1. func solution(_ num: Int) -> Int {
  2.   var result:Int = 0
  3.   if num >= 3 {
  4.     for i in (3...num - 1) {
  5.       if (i % 3 == 0 || i % 5 == 0) { result += i}
  6.     }
  7.   }
  8.   return result
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement