• ## Basic data structure and algorithm primality test / Fermat test

Time：2021-10-8

origin Recently read < < my first algorithm book > > ([Japan] Ishida Baohui; Miyazaki Xiuyi)This series of notes is intended to use golang exercises Primality test Prime test is a test to judge whether a natural number is prime. Prime number is a natural number that can only be divided by 1 and itself […]

• ## GMP extended learning for operating arbitrary precision size in PHP

Time：2021-9-9

For all kinds of development languages, integers have a maximum number of digits. If they exceed the number of digits, they cannot be displayed or operated. In fact, this is also a problem of accuracy loss after the accuracy exceeds the limit. In our PHP code, the largest integer is very large. We can use […]

• ## The golang implementation calculates prime numbers in the range of 1 to 100000

Time：2021-9-2

1. Calculate the prime number in the range of 1 to 100000, and implement golang package concurrentdemo import ( “fmt” “sync” ) //1-10000000 Var start int = 0 // start value //Var end int = 1000000 // end value var end int = 1000 Var interval int = 100 // divide goroutine interval var wg […]

• ## [recursion and recursion] n queen problem, prime ring

Time：2021-8-24

n-queens problem N queens are placed on the n * n checkerboard so that they do not attack each other (that is, any two queens are not allowed to be in the same row, the same column, or on the slash at a 45 angle with the checkerboard border).Your task is to find out how […]

• ## [Special Topics in number theory] finding prime pairs, a / B + C / D

Time：2021-8-16

Finding prime pairs Goldbach guesses that everyone knows something. We don’t want to prove this conclusion now, but want to take out an even number arbitrarily from the number set that can be expressed in the program language to find two prime numbers so that the sum is equal to the even numberIf this fact […]

• ## [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 […]