Write a Program to check whether a given number is exist in the Fibonacci series?

<?php

$num = 2;   

   if(($num==0)||($num==1))

   {

     echo "$num is exists in Fibonacci series";

   }

    else

    {

     $l=0;

     $k=1;

     $m=$l+$k;

     while($m<$num)

    {

      $l=$k;

      $k=$m;

      $m=$l+$k;

   }

    if($m==$num)

     echo "$num is exists in Fibonacci series";

    else

     echo "$num is not exists in Fibonacci series";

 }

 ?>

0   0
Aditya Singh
profile marget 27th March 2023

Trucking is a career that can be rewarding and challenging. Those who enter the industry must be reliable, responsible and hardworking, as the job involves long hours, safety regulations, and potentially hazardous conditions. Despite the challenges, the trucking industry is an important part of the economy, and those who choose to pursue it may find it to be a rewarding and satisfying career. https://trucksbuddy.com/best-lift-kit-for-ford-maverick/

 

Write a comment ...
Post comment
Cancel
profile Ranjeet 7th April 2016
Above program will work to check the number existence in Fibonacci series
Write a comment ...
Post comment
Cancel

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site