Reiterating to this logic in Swift:
import UIKit func solve(sum: Int, hcf: Int) -> (Int, Int)? { let x = 1 var y: Int! y = sum - hcf let verificationInt: Float = Float((hcf + y)/hcf) let verificationSum = Int(verificationInt + 1) if verificationSum % hcf == 0 { return (hcf*x, y) } return nil } if let solution = solve(sum: 12, hcf: 5) { print(solution) } else { print(-1) }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Reiterating to this logic in Swift: