Tag:Prime number

  • [codes] factorial tail

    Time:2021-6-24

    Topic linkThere are two parameters base, number and number! How many zeros are there at the end of a number in base. for examplebase:10,number:10Then: 10= 3628800 with 2 zeros at the endbase:16,number:16Then: 16! = > Convert to hexadecimal = > 0x1307758000 with three zeros at the end thinking Find all prime factors of base, and […]

  • Using regular expression to judge prime code

    Time:2021-6-12

    Copy codeThe code is as follows: import re def is_prime(num): return not re.match(r”^1?$|^(11+?)\1+$”, ‘1’ * num) This regular expression actually represents all “1” strings of aggregate length (including the special case “1”). (11+?) Denotes all integers greater than or equal to 2, followed by the following 1 + denotes repeated more than once – isn’t […]

  • Prime pair conjecture

    Time:2021-5-13

    1、 Title: Topic link   Let’s define DnIt is: Dn​​=p​n+1​​−p​nWhere piIs the i-th prime. Obviously there is diFor n > 1, D ﹣ n ﹣ is even“ The prime pair conjecture holds that there are infinite pairs of adjacent prime numbers with difference of 2. Now any positive integer n (< 10) is given5), please calculate […]

  • Python problem sets

    Time:2021-4-11

    Find all prime numbers within one million The first method thinking: if the current number is I, then all the numbers smaller than int (sqrt (I)) + 1 can not be divisible. If yes, they are prime numbers theory: if we traverse all divisor J smaller than I and if J > int (sqrt (I)), […]

  • Leetcode 204

    Time:2021-4-1

    Title Requirements thinking Create an array mylist, the length of which is n, and initialize all elements of the array to true Create another array res to hold prime numbers The 0 subscript position of the array is assigned to FALS, indicating that 1 is not a prime number Traverse the array subscript 1 ~ […]

  • Use native JS to judge prime numbers and find all prime numbers between 100 and 1000

    Time:2021-3-25

    Prime number:It is also called prime number, that is, a number greater than 1 and divisible only by 1 and itself Step idea:1. For traverses the loop to find other divisors2. If the setting satisfies the condition (the counter starts from 2, excluding itself), the output will be interrupted Demand 1: judge prime (quality) number […]

  • Java introduction classic examples (1)

    Time:2021-2-18

    Java introduction classic examples (1) 1、 According to the age, the people who print out the current age are teenagers (below 18), young people (19-28), middle-aged (29-55) and old people (above 56).Upper code `import java.util.Scanner; public class TextDemo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println (“please enter the age […]

  • Finding prime numbers

    Time:2021-2-17

    At the same time as the first emperor, eradose, the first person to measure the circumference of the earth, developed the eradose sieve method thinking In the given sequence (2-N) table, all the multiples (not 0, 1, itself) of each element are erased, and all the prime numbers less than n are left Eradose sieve […]

  • Regular expression sharing for checking primes

    Time:2021-1-19

    This regular expression is shown as follows: Regular expressions for checking prime numbers or not To use this positive regular expression, you need to convert the natural number into multiple 1 strings. For example, 2 should be written as “11”, 3 should be written as “111”, 17 should be written as “11111111111”. This kind of […]

  • A more secure key generation method Diffie Hellman

    Time:2021-1-19

    A more secure key generation method Diffie Hellman Before we talked about the problem of key distribution, the world is so dangerous that if we are not careful, the communication line will be monitored, so how can we transfer the key in such an insecure line? Here we introduce Diffie Hellman key exchange algorithm. This […]

  • C language — circular structure 2 (basic part 6)

    Time:2021-1-10

    I haven’t written a blog for a long time. Recently, the project has been basically completed, and my daily study needs to be put on the agenda. Although there is no hope in the future, I’d better move forward with my head down… Don’t go into the topic. Dead cycle Soft crash:CPUoccupy100%, dual core50%The machine […]

  • recursive algorithm

    Time:2020-12-15

    catalog:1. Simple recursive definition2. The difference and relation between recursion and loop3. Classical application of recursion 1. Simple recursive definition What is recursion? (first define a relatively simple statement, which may not be true for the sake of understanding) Recursion: infinitely call its own function, each call will change a key variable, until the key […]