Popular recipes tagged "arithmetic"http://code.activestate.com/recipes/tags/arithmetic/popular/2014-09-16T22:27:04-07:00ActiveState Code RecipesA Fun Perfect Square Checker Using Integer Arithmetic Only... ;o) (Bash)
2014-09-16T22:27:04-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578934-a-fun-perfect-square-checker-using-integer-arithme/
<p style="color: grey">
Bash
recipe 578934
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/arithmetic/">arithmetic</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/perfect/">perfect</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/square/">square</a>).
</p>
<p>A recent Python upload here gave me the inspiration to do a bash version...
This is a little tongue-in-cheek but an enjoyable bit of fun.</p>
<p>It took around 11 seconds to prove 90000000000 had a perfect square of 300000...</p>
<p>It is a stand alone program and has a degree of INPUT error correction...</p>
<p>It was done on a MacBook Pro, OSX 10.7.5, default bash terminal and should work on Linux flavours but it is untested...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Simple polynomial class (Python)
2014-02-13T20:55:55-08:00Sam Dentonhttp://code.activestate.com/recipes/users/4172262/http://code.activestate.com/recipes/576953-simple-polynomial-class/
<p style="color: grey">
Python
recipe 576953
by <a href="/recipes/users/4172262/">Sam Denton</a>
(<a href="/recipes/tags/arithmetic/">arithmetic</a>, <a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/polynomial/">polynomial</a>).
Revision 7.
</p>
<p>This implements polynomial functions over a single variable in Python. It represents the polynomial as a list of numbers and allows most arithmetic operations, using conventional Python syntax. It does not do symbolic manipulations. Instead, you can do things like this:</p>
<pre class="prettyprint"><code>x = SimplePolynomial()
eq = (x-1)*(x*1)
print eq # prints 'X**2 - 1'
print eq(4) # prints 15
</code></pre>