Happy Monday! Hopefully not too many people are on vacation this week.
Today's problem is an easy one but may prove interesting. Without using the multiplication operator, how can you multiply an integer by 7?
Happy Monday! Hopefully not too many people are on vacation this week.
Today's problem is an easy one but may prove interesting. Without using the multiplication operator, how can you multiply an integer by 7?
Permalink: http://problemotd.com/problem/seven-multiplication/
Content curated by @MaxBurstein
Comments:
Anonymous - 10 years, 4 months ago
C# extension method for N * M.
reply permalink
xTibor - 10 years, 4 months ago
With shifting and addition in C/C++:
int mul7(int a) { return (((a<<1)+a)<<1)+a; }
reply permalink
David - 10 years, 4 months ago
Why not use subtraction?
int mul7(int a) { return (a<<3)-a; }
reply permalink
Driphter - 10 years, 4 months ago
Clojure!
reply permalink