SHARE
TWEET

Untitled

a guest Mar 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function findnumber($numbers)
  4. {
  5.     $count = count($numbers);
  6.     for ($i = 1; $i <= $count; $i++)
  7.     {
  8.         $flag = true;
  9.         for ($j = 0; $j < $count; $j++)
  10.         {
  11.             if($numbers[$j] <= 0) continue;
  12.             if($i == $numbers[$j]){
  13.                 $flag = false;
  14.                 break;
  15.             }
  16.         }
  17.         if($flag){
  18.             return $i;
  19.         }
  20.     }
  21. }
  22.  
  23. $numbers = array(12, 7, 28, -2, 30, 5, 33, -8, 1, 2);
  24. print "for reference ";
  25. print_r($numbers);
  26. print "\nsmallest +ve missing number is ";
  27. echo findnumber($numbers);
  28. print "\n";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top