8

Hello, Makers! We’re excited to announce the Maker of the Month challenge of August. What is the challenge you might wonder? We'll challenge you with a new challenge based on the new release every month, the perfect opportunity to test and to show off your Mendix skills. Whoever provides the most detailed answer with the best explanation, receives a free fancy Mendix t-shirt and a ‘Maker of the Month’ badge on your developer's profile. This month the winner of the maker of the month will also win a seat at the exclusive live workshop at Mendix World 2.0 given by Hannah Fry, where attendees will gain some valuable insights around data analysis. Challenge: In the spirit of working with data, we thought we would base this month's challenge to be about a famous number pattern, the Fibonacci series. The challenge is to create a single microflow, which would generate the Fibonacci sequence up to the 10th number in the series. Here is the expected output of the microflow: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 Post a screenshot of your microflow, and remember to add annotations explaining the logic. Make sure your Mendix account is public so we know who you are as our next potential first-time winner! The winner will be announced in the next release video. Good luck everyone, and see you soon at Mendix World!

asked

Lars Theunissen

25 answers

40

Hi everybody,

All the answers I have seen so far are nice (and sometimes very creative), but have to be copied if someone wants to use it. In order to keep the Mendix community feeling alive, I created a published REST-service, accessible for the entire Mendix-community at https://fibonacci104-sandbox.mxapps.io/.

The only microflow anybody needs is therefore as simple as...:

Functionality in REST-service can also be seen on the homepage of the REST-service: https://fibonacci104-sandbox.mxapps.io/p/REST-service-microflow (because adding wide images in this post, doesn't really work)

answered

Martin Leppen

19

Hi there,

Here is my microflow. I initialize the FibonnaciList with the first Item at 0.

And then i loop until the 10^{th} number of the List.

Hope it’s a simplier and optimized microflow :)

Thx

Algo :

We are using :

- a string to return the FibonacciList, init : ‘0’

- a integer to store the current Fibonacci number, init :0

- a integer to store the next Fibonacci number, init :1

- a temp variable to calculate the sum Fib+NextFib, init :0

We iterate until we get the 10^{th} number of the Fibonacci List.

In each iteration, we are summing the Fib+NextFib into the temp, incrementing the NextFib with the temp variable and adding the Fib to the List.

At the end, we show a pop-up message with the Fibonacci List.

That’s it :)

FibonacciList: String :='0';

Fib: integer := 0;

NextFib: integer := 1;

Tmp : integer := 0;

begin

while Fib!=34 Loop

Tmp := Fib+ NextFib;

Fib := NextFib;

NextFib := Tmp;

FibonacciList:=FibonacciList +','+Fib

end loop;

alert(FibonacciList);

end fib;

answered

Aliah Harrosh -TocnDix

13

Less is more!

The logic is simple; “the next number is found by adding up the two numbers before”. The solution can be as elegant and simple as the logic by using recursion.

Initiate the sequence:

Result:

That’s all folk!

Cheers,

Andries

answered

Andries Smit

9

So I start the microflow with variables for:

- The sequence string to show as message as output

- A counter for the number of tries the loop will take

- A variable for the first number (default 0)

- A variable for the second number ( default 1)

- Then it sets the start of the sequence in the string variable i.e: 0,1 ($First + ‘, ‘ + $ Second)

- Then i create a outcome variable which does the $First + $ Second

- Then i add the $Outcome to the string sequence

- Then we check if the number of tries is 10 (could be anything)

- If not I change the $First variable to $Second, change the $Second variable to $Outcome and add the number of tries + 1

- Then run the loop again untill it reaches the 10^{th} trie.

Outcome: ‘Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144’

answered

Maarten Bongers

9

You have all gone way overboard. This is the challenge:

**“ The challenge is to create a single microflow, which would generate the Fibonacci sequence up to the 10 ^{th} number in the series. “**

So here is the only correct solution that does not do more than asked and does not waste processing power calculating an fixed outcome time an time again:** **

By the way: Wouldn’t it be nice to have a tool for sharing your microflow with other developers….

*Editted* On second thought I had some inspiration and have come up with another Fibonacci-microflow which I hope you all like. Check it out on https://mydemoversion8-sandbox.mxapps.io/p/Fibonacci under tab "Fibonacci to the 10th”

*Editted again* For persons that prefer to see a parameter as input and a generated Fibonacci-flow, all you need is this:

Used type long for the numbers so you can go up to 92 to get the Fibonacci-serie. You can test it at https://mydemoversion8-sandbox.mxapps.io/p/Fibonacci under tab “Fibonacci by parameter”.

answered

Tim van Steenbergen

5

Microflow

Output

answered

Nirmalkumar

5

answered

Javith Baig

5

Hi Team,

I have created simple microflow to create a fibonacci series with detail explanation using annotation.

answered

Stella D

5

Hi Fellow Mendix makers

here is my answer – the solution can also be found at: https://makerofthemonthaug2020-sandbox.mxapps.io/index.html?profile=Responsive

my solution consists of 3 parts.

- input screen where you can de desired length of the Fibonacci sequence

- A MF to deal with the requested nr of values and the generation of the answer string:

- This is the actual recursive MF that returns the actual value’s

that’s all folks – see you at Mendix World 2020.

answered

Han Pieter Duyverman

4

Hi,

Here I have post microflow of fibonacci series and added annotations too

Thanks,

Priya

answered

Priya Sekar

3

Here is my solution.

answered

Tom Staes

2

Here is my answer. You pass in how many results you want in your sequence in ‘n’. So if we pass in 10, we get ‘0, 1, 1, 2, 3, 5, 8, 13, 21, 34’. We shortcut if n is 0 or 1 as we don’t need to iterate to find the starting values.

We can call SUB_Fib like this...

So passing in 10 to SUB_Fib gives us

answered

Robert Price

2

Steps:

**Initializations:**Need to create 4 interger variables CurrentValue=1,preceedigValue=0,iterator=2, buffer=currentValue and the output string initialized with “series=’0, 1, ‘.**Condition:**the iterator value does not exceed 9, because already two Fibonacci digits are added, the rest 8 digits needed to be added. when once the iterator ticks with the value 9 then the exclusive split follows the false path as the condition breaks and will display the output as shown in the below**Data manipulations:**

a. change the buffer value with the current value.

b. change the current value with the sum of currentvalue and precedingValue ($currentValue+$preceedingValue).

c. change the preceding value with the buffer value.

d. change the series as the follows

if $iterator = 9

then’

$Series+toString($currentValue)

else

$Series+toString($currentValue)+', '

e. incrementing the iterator.

answered

Sairam Tanniru

2

My way to create Fabonacci series using Mircroflow:

Output:

answered

TY Kueh

2

OK, I am a bit late to the party, but here is my microflow:

Also, I made a page where I could specify the number of entries to generate. Here is a video of this page in action: https://youtu.be/XBTvPx7hEno

Here are the results showing the sequence

answered

Mike Kumpf

2

I’m quite new to Mendix, just in my third week, and having seen everyone elses solutions I thought I’d try something a bit different. I’ve used a list variable, based on a non-persistable entity, and a recursive loop to generate the values. This could be optimised by nesting a sub-microflow but that wasn’t part of the challenge.

Apologies for the weird shape of the flow but I’ve tried to compress it to make it more readable in a screen shot.

answered

Adam Reynolds

2

Here goes! See annotations for more information

answered

Marco Bouwkamp

2

Hi girls & guys,

I looked for a solution without hardcoding (besides the starting zero). I added a little flexibility to be able to change the desired number of numbers in the generated Fibonacci sequence, this by using an integer constant (duh). I couldn’t help to add in a small error handler to avoid negative numbers (you’ll see what I mean).

Enjoy the tropical weekend everybody :-)

answered

Jeroen De Smedt

2

Hi All,

In this comment, I cannot view the image as a single piece even I cannot resize the Image So I am splitting the Image as two If anyone has an idea of how to edit a wide image please reply in the comment I tried many ways compressing the Image but nothing worked.

In the above microflow, I created objects So I can able to display the series

the above Image is just continuation of the first Image

The above shows the Entity I have created to store the series

The final pic displays the output when I click on generate series

answered

krishna uppalapati

2

Recursive solution not overloading action stack because it is using the followupmicroflow module.

If you are only interested in the result string (0, 1, 1, 2, ...) this may be a bit too much. You can have it easier by only using a single object. If you want to have the full picture, you can use this one. It adds a list of fibonacci Numbers to to the fibonacho sequence object and maintains the solution string. The special thing about this solution is the usage of the Follow Up microflow module that allows you to build a recursive logic where each call is handled in a new transaction in a new context. With this, you can make sure, that your action stack never grows too big.

answered

Andreas Blaesius

1

Since ‘normal’ calculation has already been done, and I was afraid someone else might snipe the Java action (well done, Javith Baig!), I decided to implement the recursive algorithm. This is of course horrible, if you want to display all the numbers, so most of the code is concerned with storing the calculated numbers so that the list can be displayed neatly.

The module contains this domain model and microflows:

First microflow:

How to calculate:

Storing the intermediate results:

And finally: transform the intermediate result to a string:

answered

Rom van Arendonk

1

using 2 entities, first entities to keep the input (n) and the output to show the final Fibonacci (xn)

The Rule is **x _{n} = x_{n−1} + x_{n−2}**

answered

Quang Nhat Tran

1

Here’s mine

answered

Dries Vanstappen

1

Code self-explanatory (as always ;-) )

answered

Boris Scharinger

0

This is my solution, with one entity to store the output

answered

Anitha Arun