Count number of solutions of x^2 = 1 (mod p) in given range
Given two integers n and p, find the number of integral solutions to x2 = 1 (mod p) in the closed interval [1, n]. Examples: Input : n = 10, p = 5 Output : 4 There are four integers that satisfy the equation x2 = 1. The numbers are 1, 4, 6 and 9. Input : n = 15, p = 7 Output : 5 There are five integ