From 0916e5446434acd1a3a8384a3e9b1d935f654140 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sat, 18 Nov 2017 15:39:32 +0100 Subject: Added multiplication of two numbers We are using an easy to implemented but extremely slow algorithm to compute the multiplication of two numbers of size n. Signed-off-by: Olivier Gayot --- number.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'number.cpp') diff --git a/number.cpp b/number.cpp index 57dbcae..fcc6dc0 100644 --- a/number.cpp +++ b/number.cpp @@ -92,6 +92,18 @@ number::operator+(const number &n) const return result; } +number +number::operator*(const number &n) const +{ + number result; + + for (number i; i < n; ++i) { + result += *this; + } + + return result; +} + /* }}} */ /* Comparison operators {{{ */ -- cgit v1.2.3