Created
December 27, 2019 10:41
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
import Foundation | |
func solution(_ a:Int, _ b:Int) -> Int64 { | |
var result = 0 | |
let max: Int | |
let min: Int | |
if a > b { | |
max = a | |
min = b | |
} else { | |
max = b | |
min = a | |
} | |
for number in min...max { | |
result += number | |
} | |
return Int64(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment