File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -71,15 +71,15 @@ Here's the full implementation. Note that the recursive algorithm is most effici
71
71
72
72
``` swift
73
73
// Karatsuba Multiplication
74
- func karatsuba (_ num1 : Int , by num2 : Int ) -> Int {
75
- let num1Array = String (num1). characters
76
- let num2Array = String (num2). characters
74
+ func karatsuba (_ num1 : Int , by num2 : Int ) -> Int {
75
+ let num1String = String (num1)
76
+ let num2String = String (num2)
77
77
78
- guard num1Array .count > 1 && num2Array .count > 1 else {
79
- return num1* num2
78
+ guard num1String .count > 1 && num2String .count > 1 else {
79
+ return multiply ( num1, by : num2)
80
80
}
81
81
82
- let n = max (num1Array .count , num2Array .count )
82
+ let n = max (num1String .count , num2String .count )
83
83
let nBy2 = n / 2
84
84
85
85
let a = num1 / 10 ^^ nBy2
You can’t perform that action at this time.
0 commit comments