LeetCode 1317. Convert Integer to the Sum of Two No-Zero Integers in F#
URL
Convert Integer to the Sum of Two No-Zero Integers - LeetCode
Code
let getNoZeroIntegers (n: int) : int * int =
let isNoZeroInteger n = string n |> Seq.forall ((<>) '0')
let rec getNoZeroIntegers' a =
if a = n then
failwith "never reach here"
else
let b = n - a
if isNoZeroInteger a && isNoZeroInteger b then
a, b
else
getNoZeroIntegers' (a + 1)
getNoZeroIntegers' 1
Comments
Join the discussionNo comments yet. Be the first to comment.