Euler function and sieve method to find Euler function

Table of Contents Euler function Definition of Euler function Formula for the Euler function Formula derivation of Euler function Euler’s theorem Typical example Code Sieve method to find Euler function Idea analysis classic examples Code Euler function Definition of the Euler function For any positive integer no no n, the Euler function φ ( no […]

Weekly competition 352 (enumeration, Essieve + double pointer, double pointer)

Reference: https://leetcode.cn/circle/discuss/501Jzp/view/ICddVf/ In languages such as cpp, 1s can probably be counted as 1e8, and the time limit is generally 2s. Your algorithm can roughly calculate n based on n. For example, n is 1e5, and you wrote an n2 algorithm to calculate 1e10. Obviously, nlogn can definitely pass the calculation. According to the range […]

33. Mathematical knowledge – prime numbers (naive sieve method + Espersky sieve method + linear sieve method)

Main content of prime number and prime number sieve algorithm 1. Basic ideas 1. Prime numbers Determination of prime numbers – trial division (complexity fixed bit O(sqrt(n)) ) 2. Decompose the prime factor – trial division (the worst is O(sqrt(n))) 3. Simple sieve method – the sieve is a multiple 4. Essieve sieve method – […]

Prime number sieves (Euclidean sieve and Euler sieve)

We use leetcode204 question counting prime numbers to explain the prime number sieve problem Description of topic: Given an integer n , returns the number of all prime numbers less than a nonnegative integer n . Example 1: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are […]

(Mathematical knowledge) Judgment of prime numbers by trial division, decomposition of prime factors, Equation and linear sieve prime numbers

Prime numbers A prime number is a natural number that has no other factors than 1 and itself among the natural numbers greater than 1. Determination of prime numbers by trial division You will find that if a number is divided into two numbers and multiplied together, then the two numbers must appear in pairs, […]