Challenge 5 – Fibonacci Sequence to X

Charlie Chambers
Charlie Chambers Experian Employee
edited June 5 in Challenges

The Fibonacci Sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,.... The next number is found by adding up the two numbers before it.

-         the 2 is found by adding the two numbers before it (1+1)

-         the 3 is found by adding the two numbers before it (1+2)

-         the 5 is (2+3)

-         and so on!

Despite seemingly abstract, the Fibonacci Sequence can be used in the real world to convert miles into kilometres and vice versa. For example, when we take any two consecutive numbers from this series, as example 13 and 21 or 34 and 55, the smaller number is in miles = the other one in kilometres or we can consider the bigger number is in kilometres = the smaller one in miles.

34 Miles = round(54.72) Kilometres = 55 Kilometres

21 Kilometres = round(13.05) Miles = 13 Miles


The challenge is, starting with a table consisting of the first two numbers in the Fibonacci Sequence (0, 1), output the Fibonacci Sequence up to a parameterised value.


Example:

Input.


Use a Workflow Parameter to set the limit of the output.


Output the Fibonacci Sequence up to the Workflow Parameter.

I hope you enjoy giving this challenge a go, there are lots of ways to be creative around solving this so I can’t wait to see some of your ideas (once you're ready, please post your solutions here). Happy problem solving 😊.

Comments

  • Pavan Rao
    Pavan Rao Experian Contributor

    Hi Everyone, I am sharing my solution here. Here's a dmxd file (v2.8.7 and above) and a Video that explains how I solved this challenge :) Thanks, Pavan


  • Henry Simms
    Henry Simms Administrator

    Kudos to those that have solved this problem by creating recursive workflows. I've taken a completely different approach and created a Fibonacci Sequence custom step using Data Studio's Java SDK.

    The step takes a single argument, the number of values of the Fibonacci sequence to generate:

    Example output when run to 100 values:

    Because the step generates data, rather than being driven by data passed in from a Source, it starts with a process node on the left. The node on the right is a standard data node, meaning values generated by the step can be used in subsequent steps, in the usual way.

    You can find the code used to create this custom step on my GitHub fork of the main SDK project. It amounts to only about 100 lines of code, most of which just constructs the step config (inputs, outputs, params) and step metadata (name, version).

    What I'm hoping to show with this step is that, with just a little Java knowledge, you can create these sort of steps quite easily.

    If you have a login to the Presales environment (https://presales.experianaperturedatastudio.com/) you can try out the step by including it in your space.