Mathematical Algorithms

Recent articles on Mathematical Algorithms

Topic :

GCD and LCM :

More >>

Prime Factorization and Divisors :

More >>



Fibonacci Numbers :

More >>

Modular Arithmetic :

  1. Modular Exponentiation (Power in Modular Arithmetic)
  2. Modular multiplicative inverse
  3. Modular Division
  4. Multiplicative order
  5. Find Square Root under Modulo p | Set 1 (When p is in form of 4*i + 3)
  6. Find Square Root under Modulo p | Set 2 (Shanks Tonelli algorithm)
  7. Euler’s criterion (Check if square root under modulo p exists)
  8. Multiply large integers under large modulo
  9. Find sum of modulo K of first N natural number
  10. How to compute mod of a big number?
  11. Modulo 10^9+7 (1000000007)
  12. How to avoid overflow in modular multiplication?
  13. Find (a^b)%m where ‘a’ is very large
  14. Find power of power under mod of a prime
  15. Number of solutions to Modular Equations
  16. Recursive sum of digits of a number formed by repeated appends
  17. Find value of y mod (2 raised to power x)
  18. Modular multiplicative inverse from 1 to n
  19. Find unit digit of x raised to power y
  20. Given two numbers a and b find all x such that a % x = b
  21. Exponential Squaring (Fast Modulo Multiplication)
  22. Subsequences of size three in an array whose sum is divisible by m
  23. Distributing M items in a circle of size N starting from K-th position
  24. Discrete logarithm (Find an integer k such that a^k is congruent modulo b)
  25. Finding ‘k’ such that its modulus with each array element is same
  26. Fibonacci modulo p
  27. Maximum subarray sum modulo m
  28. Trick for modular division ( (x1 * x2 …. xn) / b ) mod (m)
  29. Count number of solutions of x^2 = 1 (mod p) in given range
  30. Breaking an Integer to get Maximum Product
  31. Program to find remainder without using modulo or % operator

More >>

Catalan Numbers :

Euler Totient Function :

nCr Computations :

Chinese Remainder Theorem :

Factorial :

  1. Factorial
  2. Legendre’s formula (Given p and n, find the largest x such that p^x divides n!)
  3. Sum of divisors of factorial of a number
  4. Count Divisors of Factorial
  5. Compute n! under modulo p
  6. Double factorial
  7. Count trailing zeroes in factorial of a number
  8. Factorial of a large number
  9. Primorial of a number
  10. Find the first natural number whose factorial is divisible by x
  11. Count numbers formed by given two digit with sum having given digits
  12. Generate a list of n consecutive composite numbers (An interesting method)
  13. Expressing factorial n as sum of consecutive numbers
  14. Find maximum power of a number that divides a factorial
  15. Trailing number of 0s in product of two factorials
  16. Print factorials of a range in right aligned format
  17. GCD of factorials of two numbers
  18. Largest power of k in n! (factorial) where k may not be prime
  19. One line function for factorial of a number
  20. Find all factorial numbers less than or equal to n
  21. Find the last digit when factorial of A divides factorial of B
  22. An interesting solution to get all prime numbers smaller than n
  23. Calculating Factorials using Stirling Approximation
  24. Check if a number is a Krishnamurthy Number or not
  25. Find a range of composite numbers of given length
  26. Smallest number S such that N is a factor of S factorial or S!
  27. Maximum value of an integer for which factorial can be calculated on a machine
  28. Smallest number with at least n digits in factorial
  29. Last non-zero digit of a factorial
  30. Smallest number with at least n trailing zeroes in factorial
  31. Count natural numbers whose factorials are divisible by x but not y
  32. Count digits in a factorial | Set 1
  33. Count digits in a factorial | Set 2
  34. No of Factors of n!
  35. Count factorial numbers in a given range
  36. Program for factorial of a number

More >>

Prime numbers and Primality Tests :

More >>

Set Theory :

Sieve Algorithms :

More >>

Divisibility and Large Numbers :

More >>



Series :

More >>

Number Digits :

More >>

Triangles :

Algebra :

Number System :

Misc :

  1. Tau – A Mathematical Constant
  2. Interquartile Range (IQR)
  3. Simulated Annealing
  4. Break the number into three parts
  5. Pseudo Random Number Generator (PRNG)
  6. Square root of a number using log
  7. Find ways an Integer can be expressed as sum of n-th power of unique natural numbers
  8. N’th palindrome of K digits
  9. N-th root of a number
  10. Fast Fourier Transformation for poynomial multiplication
  11. Find Harmonic mean using Arithmetic mean and Geometric mean
  12. Number of visible boxes after putting one inside another
  13. Generate a pythagoras triplet from a single integer
  14. Double Base Palindrome
  15. Program for Derivative of a Polynomial
  16. Sgn value of a polynomial
  17. Represent a number as sum of minimum possible psuedobinary numbers
  18. Program to print table of a number
  19. Compute average of two numbers without overflow
  20. Round-off a number to a given number of significant digits
  21. Convert a number m to n using minimum number of given operations
  22. Count numbers which can be constructed using two numbers
  23. Find Cube Pairs (A n^(2/3) Solution)
  24. Find the minimum difference between Shifted tables of two numbers
  25. Check if a number is a power of another number
  26. Check perfect square using addition/subtraction
  27. Number of perfect squares between two given numbers
  28. Count Derangements (Permutation such that no element appears in its original position)
  29. Print squares of first n natural numbers without using *, / and –
  30. Program to evaluate simple expressions
  31. Generate all unique partitions of an integer
  32. Random number generator in arbitrary probability distribution fashion
  33. Program to convert a given number to words
  34. Make a fair coin from a biased coin
  35. Generate integer from 1 to 7 with equal probability
  36. Print all combinations of balanced parentheses
  37. Print all combinations of points that can compose a given number
  38. Implement *, – and / operations using only + arithmetic operator

Quick Links :

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



My Personal Notes arrow_drop_up