Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Efficient way to multiply with 7
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# include<bits/stdc++.h>

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<<multiplyBySeven(n);

return 0;
}