This note is about some math concepts that can be converted into that you can easily write, they'll define some useful things in maths, which are generally not in the modules, but are needed at times.
So, these programs can really help you reduce calculations, they can do the calculations for you...
New addition here
This is a program to print prime numbers till a range. (This is not written by me, but i felt like sharing because it's way useful)
Input and it prints a list of all primes till the number .
If you want it to get simple, just add the line and then wanted changes in .
This function is defined for coprime integers and , that is inverse of modulo if
It is used when you want to perform actions like division in modulo, and also, it is used in the application of CRT (The Chinese Remainder Theorem).
The Python program that prints the Inverse of a number is as follows, after you type this program and input , it will return the inverse of modulo .
is the number of ways of choosing objects from a set of identical objects.
It is defined as (where is factorial notation)
It is useful in many (almost all) Combinatorics Problems and some Number Theory problems can be designed on them.
The Python program that prints value is as follows
So when you input after typing this program, you'll obtain the output as
It is defined as the number of congruences of powers of , after which the remainder starts repeating.
See that the congruence will repeat again after , that means the remainder is repeating after multiplying by , so order of modulo is
>>> Note that order can be mentioned as the least positive integer for which (This can be treated as the definition for ).
It's easy to see that if , then we'll have,
For example, if , say for numbers and ,
So order of 8 modulo 14 is . (Though
This is an extremely important thing in modular arithmetic and tedious calculations of remainder are reduced to simpler ones.
However, it's not that easy to find order of larger integers modulo some other large integers. So here is the python code that prints Order of modulo ( if ), when you input
Note+Exercise:- Try to extend this program to numbers with (A simple manipulation will do)
This note might perhaps seem obvious to expert people, so note that it is for beginners and learners.
When I think of some new program related to Maths, I will be adding to this note.
If you all have any suggestions (additions), i would like to learn the new techniques of converting maths to Programming. Please comment and I will make sure it's included in the note.