You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
1.7 KiB
100 lines
1.7 KiB
{ |
|
"cells": [ |
|
{ |
|
"outputs": [], |
|
"cell_type": "markdown", |
|
"source": [ |
|
"# Rational numbers\n", |
|
"\n", |
|
"In julia rational numbers can be constructed with the `//` operator.\n", |
|
"Lets define two rational numbers, `x` and `y`:" |
|
], |
|
"metadata": {} |
|
}, |
|
{ |
|
"outputs": [ |
|
{ |
|
"output_type": "execute_result", |
|
"data": { |
|
"text/plain": "1//3" |
|
}, |
|
"metadata": {}, |
|
"execution_count": 1 |
|
} |
|
], |
|
"cell_type": "code", |
|
"source": [ |
|
"x = 1//3" |
|
], |
|
"metadata": {}, |
|
"execution_count": 1 |
|
}, |
|
{ |
|
"outputs": [ |
|
{ |
|
"output_type": "execute_result", |
|
"data": { |
|
"text/plain": "2//5" |
|
}, |
|
"metadata": {}, |
|
"execution_count": 2 |
|
} |
|
], |
|
"cell_type": "code", |
|
"source": [ |
|
"y = 2//5" |
|
], |
|
"metadata": {}, |
|
"execution_count": 2 |
|
}, |
|
{ |
|
"outputs": [], |
|
"cell_type": "markdown", |
|
"source": [ |
|
"When adding `x` and `y` together we obtain a new rational number:" |
|
], |
|
"metadata": {} |
|
}, |
|
{ |
|
"outputs": [ |
|
{ |
|
"output_type": "execute_result", |
|
"data": { |
|
"text/plain": "11//15" |
|
}, |
|
"metadata": {}, |
|
"execution_count": 3 |
|
} |
|
], |
|
"cell_type": "code", |
|
"source": [ |
|
"z = x + y" |
|
], |
|
"metadata": {}, |
|
"execution_count": 3 |
|
}, |
|
{ |
|
"outputs": [], |
|
"cell_type": "markdown", |
|
"source": [ |
|
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" |
|
], |
|
"metadata": {} |
|
} |
|
], |
|
"nbformat_minor": 3, |
|
"metadata": { |
|
"language_info": { |
|
"file_extension": ".jl", |
|
"mimetype": "application/julia", |
|
"name": "julia", |
|
"version": "1.2.0" |
|
}, |
|
"kernelspec": { |
|
"name": "julia-1.2", |
|
"display_name": "Julia 1.2.0", |
|
"language": "julia" |
|
} |
|
}, |
|
"nbformat": 4 |
|
}
|
|
|