-
Notifications
You must be signed in to change notification settings - Fork 2
Test 4
Vincent Oliveira edited this page Sep 6, 2016
·
1 revision
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].
//src/AppBundle/Controller/Test4Controller
public function test4Action(Request $request)
{
$n = $request->request->get('n');
$result = null;
return new JsonResponse($result, JsonResponse::HTTP_OK);
}
$ curl -H "Content-Type: application/json" -X POST -d '{ "n": 10 }' test.local/test4
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]