Skip to content
Vincent Oliveira edited this page Sep 6, 2016 · 1 revision

Tiller Test Dev Backend - Test #4

What should I do ?

Write a webservice that computes the list of the first n Fibonacci numbers. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two.

As an example, here are the first 10 Fibonnaci numbers: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34].

Where should I write my code ?

    //src/AppBundle/Controller/Test4Controller
    
    public function test4Action(Request $request)
    {
        $n = $request->request->get('n');

        $result = null;
        
        return new JsonResponse($result, JsonResponse::HTTP_OK);
    }

How can I test my code ?

$ curl -H "Content-Type: application/json" -X POST -d '{ "n": 10 }' test.local/test4
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Clone this wiki locally