karatsuba
Main Karatsuba recursive algorithm
Controller: CodeCogs
Dependents
Interface
C++
Excel
Overview
This module performs multiplication of two long positive integers using the Karatsuba algorithm, in the given numerical base.Authors
- Anca Filibiu and Lucian Bentea (September 2005)
Karatsuba Mul
std::stringkaratsuba_mul( | std::string | a | |
std::string | b | ||
int | base = 10 | ) |
References:
http://mathworld.wolfram.com/KaratsubaMultiplication.htmlNote
- When the length of either the factors is less than a certain threshold, the school multiplication algorithm is used.
Parameters
a the first factor b the second factor base Default value = 10
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
Karatsuba
std::stringkaratsuba( | std::string | a | |
std::string | b | ||
int | base = 10 | ) |
Example:
#include <codecogs/maths/arithmetic/karatsuba.h> #include <iostream> int main() { std::string a("6312341234324335"), b("346632"), c = Maths::Arithmetic::karatsuba(a, b, 8); std::cout << "The following is a base 8 operation" << std::endl; std::cout << a << " * " << b << " = " << c << std::endl; return 0; }
Output:
The following is a base 8 operation 6312341234324335 * 346632 = 2704037244536535306762
Parameters
a the first factor b the second factor base Default value = 10
Returns
- a character string corresponding to the multiplication of the given numbers
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.