Skip to content

Instantly share code, notes, and snippets.

@avighnash
Created March 23, 2019 17:23
Show Gist options
  • Save avighnash/999029877274511891ee2b5f2087be55 to your computer and use it in GitHub Desktop.
Save avighnash/999029877274511891ee2b5f2087be55 to your computer and use it in GitHub Desktop.
func calc(of num: String, _ loops: Int = 0) -> Int {
return num.count != 1 ? calc(of: String(num.compactMap({ Int(String($0)) }).reduce(0, +)), loops + 1) : loops
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment