{"id":25589,"date":"2017-10-25T20:06:56","date_gmt":"2017-10-25T14:36:56","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=25589"},"modified":"2017-10-25T20:06:56","modified_gmt":"2017-10-25T14:36:56","slug":"c-programming-efficient-way-multiply-7-2","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/c-programming-efficient-way-multiply-7-2\/","title":{"rendered":"C Programming for Efficient way to multiply with 7"},"content":{"rendered":"<p>We can multiply a number by 7 using bitwise operator. First left shift the number by 3 bits (you will get 8n) then subtract the original numberfrom the shifted number and return the difference (8n \u2013 n).<\/p>\n<p><strong>Program:<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">C<\/span> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\"># include&lt;stdio.h&gt;<br\/> <br\/>int multiplyBySeven(unsigned int n)<br\/>{  <br\/>    \/* Note the inner bracket here. This is needed <br\/>       because precedence of &#039;-&#039; operator is higher <br\/>       than &#039;&lt;&lt;&#039; *\/<br\/>    return ((n&lt;&lt;3) - n);<br\/>}<br\/> <br\/>\/* Driver program to test above function *\/<br\/>int main()<br\/>{<br\/>    unsigned int n = 4;<br\/>    printf(&quot;%u&quot;, multiplyBySeven(n));<br\/> <br\/>    getchar();<br\/>    return 0;<br\/>}<\/code><\/pre> <\/div>\n<p><strong>Time Complexity: <\/strong>O(1)<br \/>\n<strong>Space Complexity:<\/strong> O(1)<\/p>\n[ad type=&#8221;banner&#8221;]\n","protected":false},"excerpt":{"rendered":"<p>C Programming for Efficient way to multiply with 7 &#8211; Mathematical Algorithms &#8211; We can multiply a number by 7 using bitwise operator. left shift number by 3.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69866,1,74058],"tags":[74113,74117,74125,74112,74102,74097,74138,74142,74096,74130,74119,74099,74106,74123,74134,74109,74132,74115,74139,74116,74124,74143,74140,74114,74118,74126,74098,74120,74137,74133,74107,74121,74135,74136,74145,74122,74101,74129,74104,74128,74111,74110,74127,74131,74141,74103,74105,74108,74100,74144],"class_list":["post-25589","post","type-post","status-publish","format-standard","hentry","category-c-programming","category-coding","category-mathematical-algorithms","tag-3-digit-multiplication-tricks","tag-basic-math-tricks-and-tips","tag-best-way-to-multiply-money","tag-easy-multiplication-method","tag-easy-multiplication-tricks","tag-easy-tricks-to-solve-maths","tag-easy-way-to-learn-maths","tag-easy-way-to-learn-maths-tricks","tag-fast-multiplication","tag-how-to-be-fast-in-maths","tag-how-to-do-mental-math","tag-how-to-do-multiplication","tag-how-to-learn-arithmetic-easily","tag-how-to-learn-basic-maths-easily","tag-how-to-learn-math-quickly","tag-how-to-learn-maths-easy-and-fast","tag-how-to-make-maths-easy","tag-how-to-multiply-money","tag-how-to-multiply-money-quickly","tag-how-to-multiply-my-money-fast","tag-how-to-solve-math-problems-faster","tag-how-to-solve-maths-easily","tag-how-to-solve-maths-quickly","tag-how-to-study-maths-easily","tag-learn-maths-easy-methods","tag-long-multiplication","tag-making-multiplication-easy","tag-math-calculator-tricks","tag-math-techniques","tag-math-techniques-and-shortcuts","tag-math-tricks-multiplication","tag-maths-simple-tricks","tag-maths-table-tricks","tag-mental-arithmetic-techniques","tag-mental-math-shortcuts","tag-multiplication-easy-method","tag-multiplication-sums","tag-multiplication-tricks","tag-multiplication-tricks-for-2-digit-numbers","tag-new-maths-tricks-for-fast-calculation","tag-quick-multiplication-techniques","tag-short-method-for-multiplication","tag-shortcut-for-multiplication","tag-simple-tricks-of-maths","tag-speedy-maths-tricks","tag-tricks-for-multiplication","tag-tricks-for-solving-maths-problems","tag-tricks-maths-fast-calculation","tag-tricks-to-solve-maths-questions-quickly","tag-vedic-maths-multiplication-tricks"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/25589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=25589"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/25589\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=25589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=25589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=25589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}