Skip to content

Instantly share code, notes, and snippets.

@jamesmcm
Created January 20, 2014 08:01
Show Gist options
  • Save jamesmcm/8516541 to your computer and use it in GitHub Desktop.
Save jamesmcm/8516541 to your computer and use it in GitHub Desktop.
test
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Marifer algorithm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The algorithm is: \n",
"\\begin{equation*} \\text{isEven} = \\frac{n}{2} - \\frac{(n-1)}{2} \\end{equation*}\n",
"\n",
"Returns 1 for Even, 0 for Odd.\n",
"\n",
"Hit __Shift+Enter__ in the box below, to run the algorithm. "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"x = lambda x: x/2 - ((x-1)/2)\n",
" \n",
"for i in range(5):\n",
" print \"x(\"+str(i)+\"): \" + str(x(i))"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"x(0): 1\n",
"x(1): 0\n",
"x(2): 1\n",
"x(3): 0\n",
"x(4): 1\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment