## Multiply Numbers using Number Theoretic Transform

Version 1.0.2 (4.1 KB) by
Multiply very numbers (hexadecimal or decimal) together efficiently using Number Theoretic Transform (NTT)

Updated 24 Mar 2021

Large Number Multiplier using Number Theoretic Transform (NTT). Quickly multiply two large numbers (either hexadecimal numbers or decimal numbers) together (less than approximately 500,000 (32-bit segments). Inputs to the multiply() function must be hexadecimal or decimal character arrays of at least 6 characters in length. Size can be up to 4 million characters each. The NTT should provide exact results (tested on several large inputs). I went through this exercise to learn about the NTT process and how it works. Output is of the same form as the input, either hexadecimal or decimal.

For example (inputs could be significantly larger):

a='1a2b3c4e5678987691827364abcdef1234567821123aabbcceeddff463723892736452';
b='9a8b7c6d5e4f123456473829ffddee1ffeeddaaccbb238edf1823938473627837463562aabbccddeeff2345678';
c=multiply(a,b);

Output:

a='198583931643537581442143136962572284781970832530224711489217605344156699047702520914';
b='1417793757582264142991820210002764610425931296836066215122869608550065190067340067192259569688783751463851640';
Output:
c='281551058640350635133920212774963620686487650950043670801076786888070561874593787199498117484873007760364284017039572666137806333241698549708893818835351498777984006753645623564120972093198960'

### Cite As

David Hill (2023). Multiply Numbers using Number Theoretic Transform (https://www.mathworks.com/matlabcentral/fileexchange/80305-multiply-numbers-using-number-theoretic-transform), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2020b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.2