Last active
May 15, 2019 01:26
-
-
Save TheAlienMann/f67883b21f22bcc4c1d413f08666abdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
link of the challenge itself.
https://www.hackerrank.com/contests/projecteuler/challenges/euler001/problem