# [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 number
If this fact is done well, it will show that this conjecture is true
Since there can be different prime pairs to represent the same even number, it is specially required that the prime pairs sought are the two closest values
Input
The input is some even integers m (5 < m < = 10000)
Output
For each even number, two prime numbers closest to each other are output, and the sum is equal to the even number
Sample Input
20 30 40
Sample Output
7 13
13 17
17 23

``````//(number theory prime number (Euler sieve, Ehrlich sieve)
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cstdio>
#include<queue>
#include<stack>
#include<set>
#include<vector>
using namespace std;
int n,a;// Tag array
int main(){
for(int i = 1;  i <= 10000;  I + +) {// mark the table with prime mark array a [], 1 means prime, and 0 means No
a[i] = 1;
for(int j = 2; j * j <= i; j++){
if(i % j == 0){
a[i] = 0;
break;
}
}
}
while(scanf("%d",&n) != EOF){
for(int i = n/2;  i > 0;  I --) {// traverse from the middle to both sides. The two values of the first effective prime pair must be the most advanced
if(a[i] == 1 && a[n - i] == 1){
printf("%d %d\n",i,n - i);
break;
}
}
}
return 0;
}`````` #### a/b + c/d

Give you 2 scores, find their sum, and ask the sum to be the simplest form.
Input
The input first contains a positive integer t (T < = 1000), indicating that there are t groups of test data, and then t lines of data. Each line contains four positive integers a, B, C, D (0 < A, B, C, d < 1000), indicating two scores a / B and C / d.
Output
For each group of test data, two integers E and F are output, indicating that the most simplified result of a / B + C / D is e / F, and each group of output occupies one line.
Sample Input
2
1 2 1 3
4 3 2 3
Sample Output
5 6
2 1

``````//(number theory (greatest common divisor GCD () least common multiple LCM ())
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cstdio>
#include<queue>
#include<stack>
#include<set>
#include<vector>
using namespace std;
int gcd(int a,int b){
if(b == 0){
return a;
}
return gcd(b,a % b);
}
int main(){
int t = 0;
cin >> t;
int a,b,c,d;
int e,f;
while(t--){
scanf("%d%d%d%d",&a,&b,&c,&d);
e = a*d + b*c;
f = b*d;
//        printf("%d %d\n",(int)(e / gcd(e,f)),(int)(f / gcd(e,f)));
printf("%d %d\n",e / gcd(e,f),f / gcd(e,f));
}
return 0;
}`````` ## The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]