{"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[pastacode lang=\u201dc\u201d manual=\u201d%23%20include%3Cstdio.h%3E%0A%20%0Aint%20multiplyBySeven(unsigned%20int%20n)%0A%7B%20%20%0A%20%20%20%20%2F*%20Note%20the%20inner%20bracket%20here.%20This%20is%20needed%20%0A%20%20%20%20%20%20%20because%20precedence%20of%20\u2032-\u2018%20operator%20is%20higher%20%0A%20%20%20%20%20%20%20than%20\u2019%3C%3C\u2019%20*%2F%0A%20%20%20%20return%20((n%3C%3C3)%20-%20n)%3B%0A%7D%0A%20%0A%2F*%20Driver%20program%20to%20test%20above%20function%20*%2F%0Aint%20main()%0A%7B%0A%20%20%20%20unsigned%20int%20n%20%3D%204%3B%0A%20%20%20%20printf(%22%25u%22%2C%20multiplyBySeven(n))%3B%0A%20%0A%20%20%20%20getchar()%3B%0A%20%20%20%20return%200%3B%0A%7D\u201d message=\u201dC\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p><strong>Time Complexity: <\/strong>O(1)<br \/>\n<strong>Space Complexity:<\/strong> O(1)<\/p>\n[ad type=\u201dbanner\u201d]\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}]}}