Hello

I need a number from Denmark to receive sms messages online.

Who can help me get it?

# Tag: number

## The number of whales in bitcoin reaches a new all time high.

## combinatorics – What is the probability a 10 digit phone number contains at most one zero?

A telephone number consists of ten digits, of which the first digit is one of 1,2,3,4,5,6,7,8,9 (first digit cannot be zero). The others can be 0,1,2,3… 9.

What is the probability that zero appears at most once in a telephone number if all the digits ae chosen completely at random.

## php – Need help with generating a unique reference number based on the user id

I’m trying to create a unique reference ID based on the actual user ID so I don’t have to reveal the actual user ID on my site. This number will be published later using a shortcode. It is necessary to hide the real user ID and real name due to the privacy policy of my country. I was thinking of a user meta that is automatically generated after registration based on the actual user ID with a specific pattern:

- 8-digits
- contains the actual user ID
- automatically completes the remaining digits with randomly generated numbers for fixing number length

```
{user_id}{generated_nr}, max 8-digits
```

I started very simply as follows, but I can’t set the length/width of the number considering the user id, so the missing digits are filled with auto-generated numbers. I also do not know how to generate the number only for newly registered users, nor do I know how to check if the number has already been assigned to another user:

```
function add_custom_ref_id( $user_id ) {
$custom_ref_id = $user_id . wp_rand(10000000,99999999);
return $custom_ref_id;
}
add_user_meta( $user_id, 'custom_ref_id', $custom_ref_id );
```

Concerns: Will the numbers be unique? Is this method secure? How can I avoid mistakes? Maybe combining them with the first letters of their first and last name? Like;

```
Name: John Doe, User ID: 24 > 24XXXXXXJD
```

And if yes, how?

I am always open to new suggestions and thank you in advance for proposing solutions.

Best regards.

PS: I already read the older threads but apart from the fact that they do not really meet my expectations, there could be better, more secure and more efficient methods out there.

## simplifying expressions – How to assume a number to be a half integer?

For integer `x`

$left(cos 2pi xright) ^2=1$ and I can check this as follows

```
Simplify(Cos(2 (Pi) x)^2, Assumptions -> x (Element) Integers)
```

and get `1`

as an output. The same holds when `x`

is half-integer. How do I assume this in `Mathematica`

? More generally, is there a nice way to implement assumptions of the type say $xin 3mathbb{Z}+2$ without redefining variables that I use?

## python – Determine whether a number and its square are both the sum of two squares

You can speed it up by saving the squares in a set. If you wrote a function to do this, you can give it a mutable default argument for it to save all the squares instead of having to calculate them repeatedly.

```
def sum_squares(n, saved_squares=set()):
# check for sum while saving squares for future calls
if int(n**(1/2)) > len(saved_squares):
found_while_saving = False
for num_to_save in range(len(saved_squares) + 1, int(n**(1/2) + 1)):
square = num_to_save**2
saved_squares.add(square)
if n - square in saved_squares:
found_while_saving = True
return found_while_saving
# check for sum in set of already calculated squares
for square in saved_squares:
if n - square in saved_squares:
return True
if square >= n:
break
return False
```

With the numbers 5881, 2048, 2670, and 3482, it will only have to calculate any squares for the first call with the number 5881. On the other three calls it can skip to checking the set of all the already calculated squares.

## ecdsa – How is the random number R for transaction signatures created?

The nonce `k`

is supposed to be an *unpredictable* number in the range 1 to 115792089237316195423570985008687907852837564279074904382605163141518161494336, inclusive – one for each point on the curve except the point at infinity (note: *not* the size of the field, which is very slightly larger than the number of points on the curve).

One way of doing that is picking a uniformly random number in that range. This works, but makes your security crucially depend on having a good random number generator. This is a simple problem in theory, but in practice lots of problems do occur. Notable examples are the Playstation 3 codesigning system (which used a fixed constant as nonce), or a bug in Android that in some cases resulted in applications generating the same sequence of “random” numbers.

The most common (and recommended) way today is using RFC 6979. It essentially prescribes not using randomness at all at signing time, but computing the nonce using a (specific) hash function that takes the message and private key as input. Under reasonable assumptions, this is just as unpredictable to attackers (who don’t know the private key) as using actual randomness, but avoids the engineering challenges with having access to a good RNG.

One word of warning: unpredictability is a very wide concept, and has lots of pitfalls. There are actual attacks against picking a nonce that is taken from a much smaller range, or against nonces that are picked in some related way. Don’t try to be “smart” about it.

## array – I want to Prepend the Row Number of the Matrix to all Elements within that row

Platform: Mathematica

Hello all!

I have a matrix of nested lists that looks like this:

```
matrix =
{{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 0}},
{{2, 3}, {4, 5}, {6, 7}, {8, 9}, {0, 1}},
{{1, 3}, {2, 4}, {3, 5}, {4, 6}, {5, 7}}}
```

and I want to Prepend the row number ‘x’ to each of the elements within each row like this:

```
{{{x, 1, 2}, {x, 3, 4}, {x, 5, 6}, {x, 7, 8}, {x, 9, 0}},
{{x, 2, 3}, {x, 4, 5}, {x, 6, 7}, {x, 8, 9}, {x, 0, 1}},
{{x, 1, 3}, {x, 2, 4}, {x, 3, 5}, {x, 4, 6}, {x, 5, 7}}}
```

so that the final product looks like this:

```
{{{1, 1, 2}, {1, 3, 4}, {1, 5, 6}, {1, 7, 8}, {1, 9, 0}},
{{2, 2, 3}, {2, 4, 5}, {2, 6, 7}, {2, 8, 9}, {2, 0, 1}},
{{3, 1, 3}, {3, 2, 4}, {3, 3, 5}, {3, 4, 6}, {3, 5, 7}}}
```

I have played around with something like `MapIndexed[Prepend[#,x]&,matrix,{3}]`

which successfully gets me to the intermediate matrix as described above where “x” is prepended, but I can’t figure out how to make “x” conditionally equal the index of the row.

Your help is very much appreciated! Thanks so much in advance!!!

Best regards,

Taylor

## pr.probability – Estimation of required number of experiments with binomial destribution

Suppose you have an experiment that consists of several tests that return either “success” or “failure”. The longer you wait the more tests you can perform, but with limited time devising a **condition** of when do you have **enough data** is important.

Another question is if its even possible to gather enough data for a stable result in a reasonable timeframe.

- We assume the tests are independent from one another.
- Success rate is quite low (~0.001 to 0.01)
- We perform
**two different sets**of similar tests (anything said above applies to both, but the probability of success for tests from different sets can vary) - $N_1, N_2$ stand for amount of tests in two sets, while $n_1, n_2$ — for amount of successes.
- Example — $N_1=N_2=2000, n_1=15, n_2=5$.

The main question is how likely is it that both sets of tests have same, or at least **similar success rate**.

My first idea was to use binomial distribution with probability of success taken from one of the sets $p=frac{n_1}{N_1}$ and arbitratily choose a cutoff measured in amount of standard deviations between norm and actual results of second set for when we **can assume** the second set can have the same success rate.

It works sort of alright for my needs, but obviously says nothing about data verification and I’m still in darkness on whether it is actually a correct method to tackle the problem.

## versioning – When to increment build number?

I’m reading a book which says:

The third number, 719, indicates the build of the assembly. If your company builds its assembly every day, you should increment the build number each day as well.

so it means to increment build number when you recompile the source code e.g. when you modify the source code.Then of course the build number is a relatively large number as we recompile our source code a lot of times.

But according to this https://docs.microsoft.com/en-us/dotnet/api/system.version?redirectedfrom=MSDN&view=net-5.0 which says:

Build: A difference in build number represents a recompilation of the same source. Different build numbers might be used when the processor, platform, or compiler changes.

the “same source” means there is no code change, so build number shouldn’t be incremented when the source code stays the same. If this is the case, we shouldn’t be seeing a very large build number such as 719 as processor, platform, or compiler changes are very rare, a number like 3,4 is more sensible.

So do we need to increment the build number when the source code changes?