Skip to content

Commit 82faac7

Browse files
committed
Added Karatsuba's multiplication algorithm
1 parent 35e41b7 commit 82faac7

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/main/java/com/thealgorithms/divideandconquer/KaratsubaMultiplication.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// https://en.wikipedia.org/wiki/Karatsuba_algorithm
55
// https://www.geeksforgeeks.org/dsa/karatsuba-algorithm-for-fast-multiplication-using-divide-and-conquer-algorithm/
66

7-
import java.util.Scanner;
7+
package com.thealgorithms.divideandconquer;
88

99
public final class KaratsubaMultiplication {
1010

@@ -33,20 +33,5 @@ public static long karatsuba(long x, long y) {
3333

3434
return (z2 * (long) Math.pow(10, 2 * m)) + ((z1 - z2 - z0) * (long) Math.pow(10, m)) + z0;
3535
}
36-
37-
public static void main(String[] args) {
38-
Scanner sc = new Scanner(System.in);
39-
40-
System.out.print("Enter first number: ");
41-
long num1 = sc.nextLong();
42-
43-
System.out.print("Enter second number: ");
44-
long num2 = sc.nextLong();
45-
46-
long result = karatsuba(num1, num2);
47-
48-
System.out.println("Product: " + result);
49-
50-
sc.close();
51-
}
5236
}
37+

0 commit comments

Comments
 (0)