{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip install pytest\n", "#!pip install numpy\n", "!pip install git+https://github.com/laguer/primefinders#egg=primefinders" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip list" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "from primefinders import primefinders" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "'primefinders.check(n)' returns 'True' if 'n' is a prime number\n", "'primefinders.factor(n)' returns the lowest prime factor of 'n'\n", "'primefinders.factors(n)' returns all the prime factors of 'n' with multiplicity\n", "'primefinders.first(n)' returns first 'n' many primes\n", "'primefinders.upto(n)' returns all the primes less than or equal to 'n'\n", "'primefinders.between(m,n)' returns all the primes between 'm' and 'n'\n", "'primefinders.phi(n)' returns the Euler's phi(n)\n", "'primefinders.lcg(n)' example of Linear Congruential Generator\n", "'primefinders.getResult(n)' returns 'True' if 'n' getResult\n", "'primefinders.calculate(n)' returns 1 if 'n' is prime\n", "'primefinders.fermat(n)' returns 1 if 'n' is prime using fermat a ** (n - 1)) % n)\n", "'primefinders.check_complex(n)' returns 1 if 'n' might be prime it said to be complex\n" ] } ], "source": [ "primefinders.about()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.check(137)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "136" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.phi(137)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "64" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.phi(136)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "32" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.phi(64)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "16" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.phi(32)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "primefinders.phi(16)" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'1.16.3'" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy\n", "numpy.__version__\n", "#print(primefinders.__version__)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "136\n" ] } ], "source": [ "from primefinders import primefinders\n", "primefinders.phi(137)\n", "print(primefinders.phi(137))" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "136" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from primefinders import primefinders\n", "primefinders.phi(137)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "from primefinders import primefinders\n", "#import numpy\n", "import pytest\n", "\n", "#assert(numpy.__version__ == '1.15.4')\n", "#assert(primefinders.phi(137) == 136)\n", "#assert(primefinders.phi(136) == 64)\n", "assert(primefinders.check(137) == True)" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "# change this to false if you want to test exceptions\n", "assert True" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "assert(primefinders.phi(137) == 136)" ] }, { "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }