## rolling around running numbers

I’m numbering generated files with two digits 00-99 and I want to retain the last 50. The algorithm should tell me the number of the current file that I’m about to save and which of the previous files to remove.

If I scale it down to a toy version with one digits, here’s how I want it to behave.

1. As long as there are fewer than 5 files, we can just add files. This is represented in the first block below.
2. Once there are 5 previous files, the oldest one should be deleted. This is trivial as long as we haven’t reached the maximum number, here 9. This is represented in the second block below.
3. Once the highest numbers has been reached, the numbering should roll around, and here is where things get tricky. See the third block below.
__prev__    __curr__   __drop__   <no files>     0         null 0              1         null 0 1            2         null 0 1 2          3         null 0 1 2 3        4         null  0 1 2 3 4      5          0  1 2 3 4 5      6          1 2 3 4 5 6      7          2 3 4 5 6 7      8          3 4 5 6 7 8      9          4  5 6 7 8 9      0          5 6 7 8 9 0      1          6 7 8 9 0 1      2          7 8 9 0 1 2      3          8 9 0 1 2 3      4          9 

Some pseudocode to illustrate my progress:

if length(prev) < 5    curr = length(prev)    drop = null  else  if 9 not in prev    curr = (1+max(prev)) mod(10)    drop = curr-5  if 9 in prev 

… and this is where I’m stuck. I’ve experimented with subtracting 10 from each element in prev.

I’m sure it’s trivial and that It’ll hit me when I least expect it. I also have a nagging feeling I’ll find an expression that generalizes both cases (with and without max in prev).

## Name of binary encoding scheme for integer numbers

I once found on Wikipedia a nice technique for encoding $$k \in (2^{n-1}, 2^n)$$ uniformly distributed integer numbers with less then $$\log_2n$$ average bits/symbol, thanks to a simple to compute variable length code. Basically it used $$\log_2n$$ for some symbols and $$\log_2n – 1$$ for some others.

Unfortunately all my Googling has failed me. I recall something similar to “variable length binary”, but I keep ending on VLQ which are a different beast. Since I know your memory better than mine, can you help me?

## How do criminals change IMEI numbers

I am looking into mobile device fraud and found a article about stolen phones and read that mobile network providers can block IEMI numbers from most networks but i also read that criminals can change these IEMI numbers in order to regain access to a network so how is this done and what can i do to protect myself from it

## Efficient XOR calculation for a large set of numbers

I need to perform XOR operation for more than 10^9 times. For Example,

 for(int i=0;i<100000;i++)  {        for(int j=0;j<100000;j++)        {           a = i ^ j;        }  } 

But this way, the program runs indefinitely. How to do this in lesser time.
Also value of each number may be between 1 and 10^10.

## How likely is for a pseudorandom number generator to generate a long sequence of similar numbers?

How likely is for a pseudorandom number generator to generate a long sequence of similar numbers? “Similar numbers” could be same numbers, or numbers from a given range.

For example, if we consider PRNG algorithm being a simple counter counting from 0 tom MAX, the distribution is uniform and there’s a guarantee of not repeating numbers in a sequence. So, not repeating numbers does not break uniformness. But probably it breaks randomness, does it? To what extent? If so, does it mean, that the better the algorithm, the less guarantee we have to not generate similar numbers in sequence?

I’m particularly interested in the answers regarding Mersenne Twister as a most popular PRNG in programming languages implementations. It’d also be great to know how things are in operating systems’ crypto-secure PRNGs – Yarrow (macOS), Fortuna (FreeBSD) or ChaCha20 (Linux).

## Prove that for all functions g: N -> R>=0, and all numbers a in R>=0, if g in Omega(1) then a + g in Theta(g)

Here is a more readable version of the question:

Prove that for all functions $$g: \mathbb{N}\to\mathbb{R}^{\geq 0}$$, and all numbers $$a \in \mathbb{R}^{\geq 0}$$, if $$g \in \Omega(1)$$ then $$a + g \in \Theta(g)$$

What I’ve done so far:

In order for $$a + g\in\Theta(g)$$, $$a+g \in \mathcal{O}(g) \wedge a + g \in \Omega(g)$$.

Expanding our assumption, we get:

$$\exists c_1, n_1 \in \mathbb{R}^{+}, \forall n \in \mathbb{N}, n \geq n_1 \implies g(n) \geq c_1$$

Proving $$a + g \in \Omega(g)$$:

Expanding the definition, we get:

$$\exists c_2,n_2 \in \mathbb{R}^{+}, \forall n \in \mathbb{N}, n \geq n_2 \implies a + g(n) \geq c_2*g(n)$$

Let $$c_1 = 1$$ and $$n_2 = n_1$$. Let $$n \in \mathbb{N}$$. Assume $$n \geq n_2$$. Prove $$a + g(n) \geq c_2 * g(n)$$.

$$g(n) = g(n)\ \implies g(n) \geq g(n)\ \Leftrightarrow c_1 * g(n) \geq c_1 * g(n)\ \Leftrightarrow g(n) \geq g(n) \text{ (since c_1 = 1 )}\\Leftrightarrow a+g(n) \geq g(n) \text{ (making left side bigger since a \in \mathbb{R}^{\geq 0} )}$$

Proving $$a+g \in \mathcal{O}(g)$$:

Expanding the definition, we get:

$$\exists c_3,n_3 \in \mathbb{R}^+, \forall n \in \mathbb{N}, n \geq n_3 \implies a + g(n) \leq c_3 * g(n)$$

I’m struggling here since I’m not really sure what value of $$c_3$$ I should be using or how to derive one. (I’ve tried using my assumption of $$g(n) \geq c_1$$ but I don’t really know where to go from there). Any help is greatly appreciated and I apologize for any formatting errors in advance. Thank you.

## Addition of vectors defined over complex numbers

I want to do the following operation: Given $$k$$ vectors $$\{|v_i\rangle \}$$ each of dimension $$d$$ ($$k < d$$) where $$i$$ denotes the vector’s index, I want to add them. Symbolically I want to perform the following operation:

$$|v\rangle = \sum_{i=1}^k c_i |v_i\rangle$$

In the following case $$c_i$$‘s and $$v_{ij}$$‘s are all complex numbers. I have defined a vector “Call” such that,

Call = {c1,c2....ck} Vall = {v1,v2,v3...vk} 

Note that each vector $$v_i$$ is defined to be

vi = {vi1, vi2,...vid} 

So basically I want the final expression to be something like this

v = {c1 v11 + c2 v21...+ ck vk1, c1 v12 + c2 v22...+ ck vk2,........ , ck v1d + c2 v2d...+ ck vkd} 

How do I implement the same?

Additional detail: In my case, $$k$$ is 104, and $$d$$ is 256.

## Diffie-Hellman in Https: How are prime numbers picked? [migrated]

I am trying to understand https, as I understand https uses the Diffie–Hellman method for keys exchange and then AES for encryption.

But Diffie–Hellman needs two prime numbers, where do these come from?

## Matrices of Machine- or Arbitrary-Precision Real Numbers Error While Using Arnoldi for Large Sparse Matrix

I’m trying to use the built in Arnoldi method in Mathematica to compute the first 1440 eigenvalues of a large sparse matrix. After importing

Elements12 = NN /@ Uncompress[Import["Elements12.m"]] and applying the followings function

NN[{a_, b_} -> c_] := {a, b} -> N[c];

I define a sparse matrix

s = SparseArray[Elements12] 

which I’m able to nicely plot using MatrixPlot

MatrixPlot[s]. 

However when it comes to finding the first 1440 eigenvalues

Sort[Eigenvalues[s, -1000, Method -> "Arnoldi"]] 

I receive the error that “Method -> Arnoldi can only be used for matrices of machine- or \ arbitrary-precision real numbers” despite my matrix elements being machine presicion after applying NN. My matrix is 344640 by 344640 and has 5,300,000 non zero elements. Any help will be appreciated.

## relationship between binary numbers and binomial heaps

I understand that a binomial heap can be represented as binary numbers according to the degree of each tree but what exactly is the relationship between inserting a new node into the binomial heap and incrementing the binomial number.

In addition to that, I assume that there is a relationship between performing union on two binomial heaps and adding the two binary numbers of the binomial heaps but what exactly is the relationship.

I’m looking for something like a formal / textbook definition or of the relationship (if possible)