-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathKaratsuba.java
More file actions
30 lines (25 loc) · 833 Bytes
/
Karatsuba.java
File metadata and controls
30 lines (25 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package karatsuba;
import java.util.Scanner;
public class Karatsuba {
public static void main(String[] args) {
String x, y;
int a, b ,c, d, ac, ad, bc, bd, answer;
Scanner sc = new Scanner(System.in);
System.out.println("Enter X: ");
x = sc.nextLine();
System.out.println("Enter Y: ");
y = sc.nextLine();
a = Integer.parseInt(x.substring(0, 2));
b = Integer.parseInt(x.substring(2, 4));
c = Integer.parseInt(y.substring(0, 2));
d = Integer.parseInt(y.substring(2, 4));
ac = a * c;
ad = a * d;
bc = b * c;
bd = b * d;
answer = ac * 10000;
answer += ((ad+bc)*100);
answer += bd;
System.out.println("The answer is: "+answer);
}
}