Skip to content

Instantly share code, notes, and snippets.

@TheAlienMann
Last active May 15, 2019 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheAlienMann/f67883b21f22bcc4c1d413f08666abdf to your computer and use it in GitHub Desktop.
Save TheAlienMann/f67883b21f22bcc4c1d413f08666abdf to your computer and use it in GitHub Desktop.
func sumOfMultiplesOfThreeAndFiveBelowN(inputs: [UInt64?]) {
for input in inputs {
var res: UInt64 = 0
if let num = input, num > 0 {
for i in 1..<num {
if i % 3 == 0 || i % 5 == 0 || ((i % 3 == 0) && (i % 5 == 0)) {
res += i
}
}
print(res)
}
}
}
sumOfMultiplesOfThreeAndFiveBelowN(inputs: [2, 10, 100])
@TheAlienMann
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment