{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Berechnen des Binomialkoeffizienten" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Link zu einem Tool für die Berechnung von Binomialkoeffizienten](https://jumk.de/kombinatorik/binomialkoeffizient.php)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Binomialkoeffizient durch Setzen von $n$ und $k$ berechnen\n", "\n", "Achtung: Das Ausführen des Python-Codes ist nur möglich, wenn man das Notebook lokal oder auf [MyBinder](https://mybinder.org/) ansieht. " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "n über k: 435\n", "5! = 120\n" ] } ], "source": [ "import scipy.special\n", "import math\n", "\n", "n = 30\n", "k = 2\n", "\n", "binnk = scipy.special.comb(n,k, exact=True)\n", "\n", "\n", "print(\"n über k:\",binnk)\n", "\n", "# Berechnen der Fakultät:\n", "fact = math.factorial(5)\n", "print(\"5! =\",fact)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }