programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Number Trick

Michael Morris
Ranch Hand
Posts: 3451
Today after church, a local high school math teacher showed me a neat little parlor trick. Take a look at the code below and see if you can figure out why it works (Jim, give everyone else a chance first ). Basically you take two random positive integers, although positive reals would also work, then begin summing them fibonacci style until you have ten integers. Then you sum all of them. By taking the seventh element and multiplying by 11 you will always get the correct sum. Here's the code:

Joel McNary
Bartender
Posts: 1840
Why 11? I'm not sure. I can of course prove this, but cannot explain why 11 is the magic number.
Likewise, if you do this for only 6 elements, the sum of all the elements is equal to 4 times the fifth element.
And if you do it for 14 elements the sum of all the elements is equal to 29 times the ninth element.
And Sum(18 elements) = 76 * the eleventh element

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Don't overlook sum(4 elements) = 4 * (3rd element)
It seems as though these sorts of relationships are not terribly uncommon in this sequence. What's special about 11? Perhaps it's just that it's easy to spot a multiple of 11 - so when some mathematician was developing formulas for sums of Fibonacci series, they noticed a couple terms with 55 and 88 in them, and said "hey look - those are divisible by 11". Which was slightly more noticeable than some of the other patterns. Well, the one I cited was pretty obvious too - just kind of boring. (Unlike all the other patterns here, of course.)
Oh, yes, while we're at it:
sum(1 element) = 1 * (1st element) :roll:
[ May 25, 2003: Message edited by: Jim Yingst ]

Michael Morris
Ranch Hand
Posts: 3451
As a parlor trick, most mathematically inclined can come up with a multiple of 11 without pencil and paper. Just ask for the seventh element and produce the answer before they even finish the series. Real Chick Magnet stuff!

Joel McNary
Bartender
Posts: 1840
Originally posted by Jim Yingst:
Don't overlook sum(4 elements) = 4 * (3rd element)

I overlooked that one because it isn't true.

For positive a and b,
3a + 4b != 4a + 4b
There only seems to be a ralationship between the sum and an element when
elements.length > 2 && elements.length % 4 == 2
Hence my citing 6, 14, and 18. (And, of couse, as you pointed out, 1 :roll: )
The real question is, given what we know, can we predict the multiple for length == 22?

Of course, I'm just assuming that a). There is an integral solution and b). The element in question will be number 13. These seems to be safe assumptions, however, given the pattern as seen so far.
(You can easily modify Michael's code to arive at the answer emperically. I would like to know how to arrive at the solution without the emperical test...)
[ May 25, 2003: Message edited by: Joel McNary ]

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Sorry, I mixed up my table of Fibonacci number formulas with my table of sums of Fibonacci number formulas. Careless. I should have said
sum(3 elements) = 2 * (3rd element)

Arjun Shastry
Ranch Hand
Posts: 1906
1
From 11, I remembered that simple trick of multiplying any number by 11.Many of you many be aware of that.e.g. 4959 X 11.
1) Write the last digit first ,i,e.9
2) Write the sum of digit and its adjacent digit to its left and carryover if more than 9.In this case,W'll write 4 ,and 1 as a carry over.
3)Repeat the step 2 until you reach the leading first digit,in this case 4.
Remember ,number should be written as 04959.

Joel McNary
Bartender
Posts: 1840
Originally posted by Jim Yingst:
Sorry, I mixed up my table of Fibonacci number formulas with my table of sums of Fibonacci number formulas. Careless. I should have said
sum(3 elements) = 2 * (3rd element)

Ah, that makes it better.
The pattern for predicting x (x = f(count) happens to be:
f(count) = 3* f(count-4) - f(count-8)
Note that since there is no closed-form formula for predicting the nth element of the Fibbonici sequence, there is no closed form formula for predicting these numbers (you just have to work on what you already know)
The Element in question is (count+4)/2
This means, of course, that for length 22, the element is question is (22+4)/2, or 13, and the number is 3*76 - 29, or 199.
The interesting thing is working backwards. If we allowed count = 2, then Element # = 3 (count + 4) / 2. This would make little sense, unles we changed out definition of the problem a little so that we are calculating the sum of the first count elements, thereby permitting elements beyound count. Solving (backwards) for x, we get x = 1 (x = 4 * 3 - 11). Therefore, the sum of the first two elements is equal to 1 * the third element.
This is just a little less insightful (and is certainly less of a Chick Magnet ) than any of the other examples, but it does fit the pattern and thereby satisfies my obsession with this problem.

Jim Yingst
Wanderer
Sheriff
Posts: 18671
...and is certainly less of a Chick Magnet ...
It is hard to understand why there aren't more hot babes drawn in to these discussions.

Michael Morris
Ranch Hand
Posts: 3451
It is hard to understand why there aren't more hot babes drawn in to these discussions.
Go figure!

Ranch Hand
Posts: 1873
yeah
i found the generalization!!!
i will post it provided i can write in on paper and scan it.
i will write a program to get f(n) for fibo things so u can make sure about the answer.
i used to love math once upon a time.
regards
maulin

Michael Morris
Ranch Hand
Posts: 3451
i will write a program to get f(n) for fibo things so u can make sure about the answer.
I know a high school math teacher that will be very happy to know the solution.

Ranch Hand
Posts: 1873
hi all,
here is the C code that i wrote to find out the general solution.

here, this will fail for case 1 that is count=6. and in this specific case i observe that the 'x' is 4 which is "square root" of "2" and i 've some "magical predictions" based on my theory that might lead us to something concrete decision but i can't explain it here as i have not mentioned how did i came up with the above program?
(thats why i told that i would provide the scanned page where i have the logic to come up with the above code. i will try to do it).
regards
maulin

Ranch Hand
Posts: 1873
btw,
sorry for writing C code but i just felt 'attracted' to write this in C rather than in Java. i donno why.
regards
maulin

Joel McNary
Bartender
Posts: 1840
Fascinating code. I played around with it for a little bit and see what it's doing, but I would love to know why it works.
For those of you who do not have a C-compiler installed (like me), here is the Java version (I renamed the function names to make it more readable to non-mathematicians)

Ranch Hand
Posts: 1873
hi all,
i have scanned 5 pages where i have written the apporach i had. all the pages are scanned in GIF format and i have a winzip file created for it but how do i post here?
regards
maulin

Joel McNary
Bartender
Posts: 1840
You can't actually post it directly here on the boards, but you can publish it to a different web site and then link to it (preferably using the [ URL ] tag.

Ranch Hand
Posts: 1873
well,
thats the essential problem i have. i dont have any URL where i can upload it. i had my school's site but now it doesn't work after i graduated
can i send it to any of you in email, who can in turn upload it on some site and use the url tag to make it available to all?
regards
maulin

Michael Morris
Ranch Hand
Posts: 3451
You can upload them to my company site. I set you up an account and I'll send you a private message giving you the specifics. Once you upload them, I'll link them here.

Ranch Hand
Posts: 1873
hi Michael Morris,
i uploaded the file called "theory.zip" to the location you provided.
thank you very much for the help.
let me know if you find problems in accessing the file or anything.
regards
maulin

Michael Morris
Ranch Hand
Posts: 3451
I tried linking the GIFs here but they were so huge I deleted the post. I'm going to convert them to jpegs and then post them.

Michael Morris
Ranch Hand
Posts: 3451
Here are Maulin's GIFs

Thanks again Maulin

Ranch Hand
Posts: 1873
hi all,
also to reach on more simple solution,
we can say that if we are given "count" then,
# = (count+4)/2.
e.g.
count = 6, # = 5
count = 10, # = 7
count = 14, # = 9 etc...
and from my theory after simplification of index starting from 1 instead of 0 we can derive,
constant 'x' = [F(count) -1]/F(count/2)
Where,
F(i) = is the i th term in classic fibonacci series and i starts from 1.
=>
F(1) = 0,
F(2) = 1,
F(3) = 1 etc...
count = 10, F(10) = 34, F(5) = 3 and so,
'x' = (34 - 1)/3 = 11.
count = 14 , F(14) = 233, F(7) = 8 and so,
'x' = (233-1)/8 = 29 and so on...
regards
maulin