From f7e08204899d7b0499bd7876921884846bf19c76 Mon Sep 17 00:00:00 2001 From: ashishkore <43812466+ashishkore@users.noreply.github.com> Date: Thu, 31 Oct 2019 21:57:32 +0530 Subject: [PATCH] Create Efficient way to multiply with 7 --- Efficient way to multiply with 7 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Efficient way to multiply with 7 diff --git a/Efficient way to multiply with 7 b/Efficient way to multiply with 7 new file mode 100644 index 0000000..03bffb1 --- /dev/null +++ b/Efficient way to multiply with 7 @@ -0,0 +1,21 @@ +# include + +using namespace std; +//c++ implementation +long multiplyBySeven(long n) +{ + /* Note the inner bracket here. This is needed + because precedence of '-' operator is higher + than '<<' */ + return ((n<<3) - n); +} + +/* Driver program to test above function */ +int main() +{ + long n = 4; + + cout<