Karatsuba Algorithm
Karatsuba Algorithm
APPLICATION:
-> Used in cryptoGraphy(RSA and where large number multiplication is common).
-> Large integer Arithmetic; requiring precise calculations for larger numbers.
-> Extends into faster Multiplication algorithms such as TOOM COOK and Schönhage -
Strassen algorithms.
CODE:
import java.util.*;
class Karatsuba{
static int karatsuba(int x, int y){
int a = x / factor;
int b = x % factor;
int c = y / factor;
int d = y % factor;
int ac = karatsuba(a,c);
int bd = karatsuba(b,d);
}
static int getNumDigits(int a){
int digits = 0;
while(a != 0){
a /= 10;
digits++;
}
return digits;
}
int x = input.nextInt();
int y = input.nextInt();
System.out.printf("The karatsuba product of %d and %d is %d", x, y,
karatsuba(x, y));
}
}