| |

VerySource

 Forgot password?
 Register
Search
View: 1357|Reply: 7

Find a mathematical algorithm for generating a sequence of values ​​that is as non-repeating as possible based on a

[Copy link]

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-2-7 16:00:01
| Show all posts |Read mode
Suppose there are input sequences, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... n
Requires the output of a sequence similar to a random number without any regularity
Let's say, 234, 78, 123, 87, 32, ...
The output sequence can be repeated, but the probability of repetition is as low as possible, preferably not greater than 5%

Don't use ready-made random functions like rand ()
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-3-30 08:30:01
| Show all posts
I don't understand what the landlord said is input 1 to n.
Reply

Use magic Report

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-3-30 19:15:01
| Show all posts
look at this:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
The corresponding output is:
6,15,28,45,66,91,120,153,190,231

See if there are any rules?
Reply

Use magic Report

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-3-31 10:00:01
| Show all posts
It's not very useful. Haha.
I now want to use it in the distribution of shareware serial numbers.

It is to do a transformation so that one cannot guess the algorithm based on several inputs and results.
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-4-2 01:15:01
| Show all posts
An = 2 * n * n + 3 * n + 1

If it is a small amount, you can use the last 3 digits of the system time (xxx microseconds), or read a piece of binary data from anywhere (hard disk, memory, files ... It should not matter if it is a little regular), just deal with it Make use of
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-6 10:15:01
| Show all posts
md5 convert it
Reply

Use magic Report

3

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-4-13 20:00:01
| Show all posts
stoneboy4000
How did you come out?
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-13 21:15:01
| Show all posts
First look at why your sequence is so fragile

f (1) = 6, f (2) = 15, f (3) = 28, f (4) = 45 ....
 
==> f (2) -f (1) = 9; f (3) -f (2) = 13; f (4) -f (3) = 17; f (5) -f (4) = 21 ...
=> 13-9 = 4, 17-13 = 4, 21-17 = 4 .... Obviously an arithmetic sequence

=> f (n) -f (n-1) = 4 (n-1) +5 (n> 1). From this recurrence relationship, you can get the result.

Push down as follows:
f (2)-f (1) = 4 * 1 + 5;
f (3)-f (2) = 4 * 2 + 5;
f (4)-f (3) = 4 * 3 + 5;
...
f (n) -f (n-1) = 4 * (n-1) +5;
Add the above formulas => f (n) -f (1) = 2n * n + 3n-5, note that f (1) = 6.
So f (n) = 2n * n + 3n + 1

As far as your needs are concerned, you need a nonlinear pseudo-random book generator. A simple way is to define a large table by yourself, the data in it is pre-defined, and then it is non-linear (play your own imagination :)).
Then use rand (n), (n = 1,2, ...) to generate a number, use the even bits of this number to determine the row, and the odd bits to determine the column, and then take out the values ​​in the table.

The key to this method is that the contents of this form must be safe. If someone disassembles it, this method will be in vain ...

If you have a high need for security, then you need a cryptographically secure pseudo-random number generator. You can search for PRNG online. There are many ready-made implementations (mostly written by foreign cryptography experts). There is no way to ensure that the National Security Agency takes your program.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list