National_Instruments
200-500 · Question #103
What is the output of the following script? 1 <?php 2 function fibonacci ($x1, $x2) 3 { 4 return $x1 + $x2; 5 } 7 $x1 = 0; 8 $x2 = 1; 10 for ($i = 0; $i < 10; $i++) { 11 echo fibonacci($x1, $x2)…
The correct answer is D. 1,1,1,1,1,1,1,1,1,1. See the full explanation below for the reasoning.
Question
What is the output of the following script? 1 <?php 2 function fibonacci ($x1, $x2) 3 { 4 return $x1 + $x2; 5 } 7 $x1 = 0; 8 $x2 = 1; 10 for ($i = 0; $i < 10; $i++) { 11 echo fibonacci($x1, $x2) . ','; 12 } 13 ?>
Options
- A1,2,3,4,5,6,7,8,9
- B1,2,3,4,5,6,7,8,9,10,
- C1,2,3,5,8,13,21,34,55,89,
- D1,1,1,1,1,1,1,1,1,1,
How the community answered
(21 responses)- A5% (1)
- B10% (2)
- C14% (3)
- D71% (15)
Community Discussion
No community discussion yet for this question.