Computer scientist Divakar Viswanath discovered a new constant of nature. Examples of constants you know well are pi ( the ratio of the circumference to the diameter of a circle) and e (the base of natural logarithms).
Viswanath has this number named after him for discovering it. He discovered the number while playing around with the Fibonacci number series. He decided to flip a coin to decide whether to add or subtract the last pair of numbers to produce the next term. He used ‘heads’ to mean add the two terms, and ‘tails’ to subtract them.
For example, the sequence HTTHHTHTTH will produce the sequence 1, 1, 2, -1, 3, 2, 5, -3, 2, -5, 7, 2. Of course, the unlikely sequence of HHHHHHHHH… will produce the original Fibonacci sequence.
Viswanath discovered that if he ignored the minus signs, the series still increased in a regular way, and with 100% probability, the position of the number in the series was 1.13198824… to the power of the position. In other words, the 100th term had the value 1.13198824…100. The higher the term was in the series, the closer it converged to that power of 1.13198824…
Write a computer program that will produce a Viswanath’s series and, for each number, calculate it’s Viswanath Constant. List the series number and it’s power in a list box.
You will need to write a function that will raise an irrational number to an integer power. The formula is: