Results 1 to 4 of 4
Like Tree1Thanks
  • 1 Post By MarkFL

Math Help - Devising an algorithm based on a pattern in a number series.

  1. #1
    Newbie
    Joined
    Nov 2012
    From
    USA
    Posts
    2

    Devising an algorithm based on a pattern in a number series.

    Hello folks,

    My name is Skyliner, I'm a computer science student and I'm making a very small program that performs some calculations based on a series of numbers.
    My problem comes from trying to improve the original algorithm used to generate such numbers. I won't go into details, suffice to say that it involves as much as 10 conditional checks modifying values arbitrarily, in order to obtain the desired numbers.

    I believe such a rudimentary approach is not only brute and inefficient, it is unnecessary. As you'll see there is a simple pattern in these numbers, a much simpler generation algorithm is bound to exist. My inferior, or rather non-existant mathematical skills, however, do not allow me to find it. Still, by pure stubbornness, I've come close to a correct formula, which sadly is not precise enough.

    I was hoping you guys could help me out.
    Thank you.

    The problem goes like this: for every given seed (level) a number must be generated that corresponds exactly to a specific value. If we increase the seed sequentially, it is easy to identify a pattern in the generated numbers. I'm looking to create a formula, that returns the appropriate value (basePrecision) for whichever level is given.
    Here are the numbers:
    Spoiler:

    Code:
    level: 1 basePrecision is: 24
    level: 2 basePrecision is: 28
    level: 3 basePrecision is: 32
    level: 4 basePrecision is: 36
    level: 5 basePrecision is: 40
    level: 6 basePrecision is: 44
    level: 7 basePrecision is: 48
    level: 8 basePrecision is: 52
    level: 9 basePrecision is: 56
    level: 10 basePrecision is: 62
    level: 11 basePrecision is: 68
    level: 12 basePrecision is: 74
    level: 13 basePrecision is: 80
    level: 14 basePrecision is: 86
    level: 15 basePrecision is: 92
    level: 16 basePrecision is: 98
    level: 17 basePrecision is: 104
    level: 18 basePrecision is: 110
    level: 19 basePrecision is: 116
    level: 20 basePrecision is: 124
    level: 21 basePrecision is: 132
    level: 22 basePrecision is: 140
    level: 23 basePrecision is: 148
    level: 24 basePrecision is: 156
    level: 25 basePrecision is: 164
    level: 26 basePrecision is: 172
    level: 27 basePrecision is: 180
    level: 28 basePrecision is: 188
    level: 29 basePrecision is: 196
    level: 30 basePrecision is: 206
    level: 31 basePrecision is: 216
    level: 32 basePrecision is: 226
    level: 33 basePrecision is: 236
    level: 34 basePrecision is: 246
    level: 35 basePrecision is: 256
    level: 36 basePrecision is: 266
    level: 37 basePrecision is: 276
    level: 38 basePrecision is: 286
    level: 39 basePrecision is: 296
    level: 40 basePrecision is: 308
    level: 41 basePrecision is: 320
    level: 42 basePrecision is: 332
    level: 43 basePrecision is: 344
    level: 44 basePrecision is: 356
    level: 45 basePrecision is: 368
    level: 46 basePrecision is: 380
    level: 47 basePrecision is: 392
    level: 48 basePrecision is: 404
    level: 49 basePrecision is: 416
    level: 50 basePrecision is: 412
    level: 51 basePrecision is: 428
    level: 52 basePrecision is: 444
    level: 53 basePrecision is: 460
    level: 54 basePrecision is: 476
    level: 55 basePrecision is: 492
    level: 56 basePrecision is: 508
    level: 57 basePrecision is: 524
    level: 58 basePrecision is: 540
    level: 59 basePrecision is: 556
    level: 60 basePrecision is: 572
    level: 61 basePrecision is: 588
    level: 62 basePrecision is: 604
    level: 63 basePrecision is: 620
    level: 64 basePrecision is: 636
    level: 65 basePrecision is: 652
    level: 66 basePrecision is: 668
    level: 67 basePrecision is: 684
    level: 68 basePrecision is: 700
    level: 69 basePrecision is: 716
    level: 70 basePrecision is: 734
    level: 71 basePrecision is: 752
    level: 72 basePrecision is: 770
    level: 73 basePrecision is: 788
    level: 74 basePrecision is: 806
    level: 75 basePrecision is: 824
    level: 76 basePrecision is: 842
    level: 77 basePrecision is: 860
    level: 78 basePrecision is: 878
    level: 79 basePrecision is: 896
    level: 80 basePrecision is: 916

    This is the formula I came up with:
    (level * .1 + 3.2) * level + 20
    It works, but it's completely off in some cases. So much that even playing around with approximation will not yield accurate results.

    PS:The seed can only be in the range 1-80.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor MarkFL's Avatar
    Joined
    Dec 2011
    From
    St. Augustine, FL.
    Posts
    1,988
    Thanks
    734

    Re: Devising an algorithm based on a pattern in a number series.

    Here is some pseudo-code that should work:

    basePrecision=20

    for n = 1 to level

    basePrecision = basePrecision + 2*int(n/10)+4

    next n
    Last edited by MarkFL; November 10th 2012 at 12:00 AM. Reason: simplify algorithm a bit
    Thanks from Petrus
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2012
    From
    USA
    Posts
    2

    Re: Devising an algorithm based on a pattern in a number series.

    Well that works quite alright.
    I was expecting a complicated math algorithm and yet you hit me with this... simple no brainer solution. I feel ashamed.

    Thank you!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor MarkFL's Avatar
    Joined
    Dec 2011
    From
    St. Augustine, FL.
    Posts
    1,988
    Thanks
    734

    Re: Devising an algorithm based on a pattern in a number series.

    Someone more knowledgeable about recursions involving the floor function may be able to provide you with a closed-form solution, but that was the best I could do in a reasonable amount of time.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Pattern recognition algorithm
    Posted in the Advanced Math Topics Forum
    Replies: 0
    Last Post: December 10th 2011, 03:35 PM
  2. Number pattern.
    Posted in the Math Puzzles Forum
    Replies: 13
    Last Post: May 8th 2010, 06:29 PM
  3. prove Euclidean Algorithm based ...
    Posted in the Number Theory Forum
    Replies: 5
    Last Post: July 10th 2008, 07:30 AM
  4. number pattern
    Posted in the Algebra Forum
    Replies: 2
    Last Post: June 18th 2008, 02:18 AM
  5. Help devising a formula
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: March 26th 2006, 10:51 AM

Search Tags


/mathhelpforum @mathhelpforum