Python program to check the validity of a Password

In this program, we will be taking a password as a combination of alphanumeric characters along with special characters, and check whether the password is valid or not with the help of few conditions.

Primary conditions for password validation :

  1. Minimum 8 characters.
  2. The alphabets must be between [a-z]
  3. At least one alphabet should be of Upper Case [A-Z]
  4. At least 1 number or digit between [0-9].
  5. At least 1 character from [ _ or @ or $ ].
[mai mult...]

Check if all digits of a number divide it with Python3

Given a number n, find whether all digits of n divide it or not.

Examples:

Input : 128
Output : Yes
128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.

Input : 130
Output : No

We want to test whether each digit is non-zero and divides the number. For example, with 128, we want to test d != 0 && 128 % d == 0 for d = 1, 2, 8. To do that, we need to iterate over each digit of the number.

[mai mult...]

Python Script for Number of solutions to Modular Equations

Given A and B, the task is to find the number of possible values that X can take such that the given modular equation (A mod X) = B holds good. Here, X is also called a solution of the modular equation.

Examples:

Input : A = 26, B = 2
Output : 6
Explanation
X can be equal to any of {3, 4, 6, 8,
12, 24} as A modulus any of these values
equals 2 i. e., (26 mod 3) = (26 mod 4) 
= (26 mod 6) = (26 mod 8) =Output:2 

Input : 21 5
Output : 2
Explanation
X can be equal to any of {8, 16} as A modulus 
any of these values equals 5 i.e. (21 mod 
8) = (21 mod 16) = 5
[mai mult...]

Python Script for Legendre’s Conjecture

Conjecture: A conjecture is a proposition or conclusion based upon incompleate information to which no proof has been found i.e it has not been proved or disproved.

Mathematically,
there is always one prime p in the range n^2 to (n + 1)^2 where n is any natural number.

for examples:
2 and 3 are the primes in the range 1^2 to 2^2.

5 and 7 are the primes in the range 2^2 to 3^2.

11 and 13 are the primes in the range 3^2 to 4^2.

17 and 19 are the primes in the range 4^2 to 5^2.

[mai mult...]