Qbasicnews.com

Full Version: any mathematicians here?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know this isn't a math forum, but It's true that programmers are good at math and logic. So I hope someone can help me with this problem. It's not for school, it's for personal interest. I need help describing the following function mathematicaly. It's a function of the form F(n, x) that behaves like this:

(the number sequences are for all the values of x starting at x=1)

F(0, x): 0, 0, 0...

F(1, x): 1, 2, 3, 4, 5...

F(2, x): 10, 11, 20, 21, 22, 30, 31, 32, 33, 40...

F(3, x): 100, 110, 111, 200, 210, 211, 220, 221, 222, 300...

F(4, x): 1000, 1100, 1110, 1111, 2000, 2100, 2110....

etc..

These are sequences that are easy to understand the logic, but hard to form into a function. I can make a program that does this, but I need a single function. Any help is appreciated. Thanks
You could've put it into the "programming help" section, but oh well.

My thoughts are that, although it wouldn't be a "SINGLE" function, it still might work. You could do something like converting them all into string variables or something like that... then it would be easy to change a digit in the corresponding place value... but I'm not exactly sure on what it is you're trying to accomplish by doing this.
I'm not trying to make a program that produces those numbers. That's easy. A mathematical function is what I'm looking for. But thanks though
Damn!!! this is hard!! I looked at it and even tried the ol gaussian method but the sum seems a lil different from a1-an and a2-(an-1)

Anyone?
yeah it is hard. Thanks for trying though. I'm working on a series of functions that, in union, will give the real value for a continued fraction of this kind: a0+(b1/(a1+(b2/(a2+(b3/(a3+...)))))). An example of this fraction can be found here: http://mathworld.wolfram.com/ContinuedFraction.html
I've been told that there is no function that gives the direct answer. Does anyone know anything about this? Anyways, this is the last function I need to make it work and I can't figure it out. Any help is appreciated. Thanks

P.S. The x doesn't need to start at 1, it can start at 0 if it makes things simpler. It would just be a minor change in the function.
Wow, this is crazy... I have no idea how to go about it, and I've been thinking about it for some time now...
well, is it possible that there is no function asscociated? I mean, the number pattern seems more of a logical pattern than a mathematical function?
It might not exist, but I know it's possible. If there's a logical pattern, a mathematical representation can be achieved.
GGGRRRR! I understand how it works, but I can't put it in words, or in code! this really sucks.

see, it would go like this:

F(0, x): 0, 0, 0... 'duh

F(1, x): 1, 2, 3, 4, 5... 'duh

F(2, x): 10, 11, 20, 21, 22, 30, 31, 32, 33, 40, 41, 42, 43, 44, 50, 51 'etc

F(3, x): 100, 110, 111, 200, 210, 211, 220, 221, 222, 300, 310, 311, 320, 321, 322, 330, 331, 332 ,333, 400, 410, 411, 420, 421, 422, 431, 432, 433, 440, 441, 442, 443, 444, etc.

F(4, x): 1000, 1100, 1110, 1111, 2000, 2100, 2110, 2111, 2200, 2210, 2211, 2220, 2221, 2222, 3000, 3100, 3110, 3111, 3200, 3210, 3211, 3220, 3221, 3222, 3300, 3310, 3311, 3320, 3321, 3322, 3330, 3331, 3332, 3333, 4000, etc.

F(5,x): 10000, 11000, 11100, 11110, 11111, 20000, 21000, 21100, 21110, 21111, 22000, 22100, 22110, 22111, 22200, 22210, 22211, 22220, 22221, 22222, 30000, 31000, 31100, 31110, 31111, 32000, 32100, 32110, 32111, 32200, etc.
I found a lot of important data that is really important to this problem. Look at these sequences:
1,2,3,4,5...
1,3,6,10,15...
1,4,10,20,35...

We all know these sequences from the binomial coefficient formula or from pascals triangle (look diagonal-down-right):
.........1
.......1.1
.....1..2.1
...1..3..3.1
..1..4.6..4.1
.1.51010.5.1

Anyways, you can begin to find the answer if you designate a variable k for each of these rows like this:
k=1 : 1-2-3-4-5...
k=2 : 1-3-6-10-15...
k=3 : 1-4-10-20-35...
etc...
Now this is the algorithm. So you start at k=n from the rows above and you take the number smaller or equal, but closest, to x. So if n = 3, and x = 6, you go to row k3, and the smallest or equal number closest to x equals 4, which is digit position 2. So F(3,6) = 2 _ _ . Next, you substract the 4 from x which gives you 2. Now, you decrease k by one. So what number on row k2 is smaller or equal but closet to 2? the answer is 1, which is digit 1 on the row. So, now we have F(3,6)=21 _ . Next, we substract 1 from 2 which we now have 1. Now we decrease k to 1. We do the same thing, and we now have F(3,6) = 211 which is the right answer. Whew, that was tough explaining. So the difficult part of this algo is coming up with a mathematical equation that gives you the smallest or equal number, closest to x on row k. After that, it would be easy to put into the function. And, suppose you have n=3 and x =4, which should be 200 for the answer, the algo would give you a 2 for the first digit which is right, but it would have to give you a 0 for the next 2. Since the binomial coefficients are involved, you can`t produce a 0 if you`re using r!/(d!(r-d)!). Anyways, I hope this info inspires people to continue solving this difficult problem. And thanks for all the help and effort Smile