How do I go about multiplying a real number n by 6 in python without using the * or the + operators?
Solution:
x6 = lambda n: (n<<3) - n - n
Rationale:
n<<3 is equivalent to multiplying n by 2**3 or 8n. To reach 6n, we simply subtract 2n.
Your email address will not be published. Required fields are marked *
Name *
Email *
Website
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>