# primitive root of 7

Return -1 if n is a non-prime number. Email: donsevcik@gmail.com Tel: 800-234-2933; Primitive Root Video. # This is checked so that we can skip a \equiv \big(g^z \pmod{n}\big). For every number r, compute values of r^x(mod n) where x is in range[0, n-2]. of digits in any base, Find element using minimum segments in Seven Segment Display, Find nth term of the Dragon Curve Sequence, Find the Largest Cube formed by Deleting minimum Digits from a number, Find the Number which contain the digit d. Find nth number that contains the digit k or divisible by k. Find N integers with given difference between product and sum, Number of digits in the product of two numbers, Form the smallest number using at most one swap operation, Difference between sums of odd and even digits, Numbers having difference with digit sum more than s, Count n digit numbers not having a particular digit, Total numbers with no repeated digits in a range, Possible to make a divisible by 3 number using all digits in an array, Time required to meet in equilateral triangle, Check whether right angled triangle is valid or not for large sides, Maximum height of triangular arrangement of array values, Find other two sides of a right angle triangle, Find coordinates of the triangle given midpoint of each side, Number of possible Triangles in a Cartesian coordinate system, Program for dot product and cross product of two vectors, Complete the sequence generated by a polynomial, Find the minimum value of m that satisfies ax + by = m and all values after m also satisfy, Number of non-negative integral solutions of a + b + c = n, Program to find the Roots of Quadratic equation, Find smallest values of x and y such that ax – by = 0, Find number of solutions of a linear equation of n variables, Write an iterative O(Log y) function for pow(x, y), Count Distinct Non-Negative Integer Pairs (x, y) that Satisfy the Inequality x*x + y*y < n, Fast method to calculate inverse square root of a floating point number in IEEE 754 format, Check if a number is power of k using base changing method, Check if number is palindrome or not in Octal, Check if a number N starts with 1 in b-base, Convert a binary number to hexadecimal number, Program for decimal to hexadecimal conversion, Converting a Real Number (between 0 and 1) to Binary String, Count of Binary Digit numbers smaller than N, Write a program to add two numbers in base 14, Convert from any base to decimal and vice versa, Decimal to binary conversion without using arithmetic operators, Find ways an Integer can be expressed as sum of n-th power of unique natural numbers, Fast Fourier Transformation for poynomial multiplication, Find Harmonic mean using Arithmetic mean and Geometric mean, Number of visible boxes after putting one inside another, Generate a pythagoras triplet from a single integer, Represent a number as sum of minimum possible psuedobinary numbers, Program to print multiplication table of a number, Compute average of two numbers without overflow, Round-off a number to a given number of significant digits, Convert a number m to n using minimum number of given operations, Count numbers which can be constructed using two numbers, Find Cube Pairs | Set 1 (A n^(2/3) Solution), Find the minimum difference between Shifted tables of two numbers, Check if a number is a power of another number, Check perfect square using addition/subtraction, Number of perfect squares between two given numbers, Count Derangements (Permutation such that no element appears in its original position), Print squares of first n natural numbers without using *, / and –, Generate all unique partitions of an integer, Program to convert a given number to words, Print all combinations of balanced parentheses, Print all combinations of points that can compose a given number, Implement *, – and / operations using only + arithmetic operator, Program to calculate area of an Circle inscribed in a Square, Program to find the Area and Volume of Icosahedron, Topic wise multiple choice questions in computer science, https://en.wikipedia.org/wiki/Primitive_root_modulo_n#Finding_primitive_roots, http://math.stackexchange.com/questions/124408/finding-a-primitive-root-of-a-prime-number, Creative Common Attribution-ShareAlike 4.0 International. # Shubham Singh(SHUBHAMSINGH10), Reference: Smallest number S such that N is a factor of S factorial or S! if (power(r, phi // it, n) == 1): # If there was no power with value 1. """ Iterative Function to calculate (x^n)%p # when n is a prime number greater than 2 for r in range(2, phi + 1): # Iterate through all prime factors of phi. return True # mod n is 1 or not xn) / b ) mod (m), Count number of solutions of x^2 = 1 (mod p) in given range, Breaking an Integer to get Maximum Product, Program to find remainder without using modulo or % operator, Non-crossing lines to connect points in a circle, Find the number of valid parentheses expressions of given length, Optimized Euler Totient Function for Multiple Evaluations, Euler’s Totient function for all numbers smaller than or equal to n, Primitive root of a prime number n modulo n, Compute nCr % p | Set 1 (Introduction and Dynamic Programming Solution), Compute nCr % p | Set 3 (Using Fermat Little Theorem), Probability for three randomly chosen numbers to be in AP, Rencontres Number (Counting partial derangements), Find sum of even index binomial coefficients, Space and time efficient Binomial Coefficient, Count ways to express even number ‘n’ as sum of even integers, Horner’s Method for Polynomial Evaluation, Print all possible combinations of r elements in a given array of size n, Program to find the Volume of a Triangular Prism, Sum of all elements up to Nth row in a Pascal triangle, Chinese Remainder Theorem | Set 1 (Introduction), Chinese Remainder Theorem | Set 2 (Inverse Modulo based Implementation), Cyclic Redundancy Check and Modulo-2 Division, Using Chinese Remainder Theorem to Combine Modular equations, Legendre’s formula (Given p and n, find the largest x such that p^x divides n!