 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP program to check if a given number is present in an infinite series or not
To check if a given number is present in an infinite series or not, the PHP code is as follows −
Example
<?php    function contains_val($m, $n, $o){       if ($m == $n)          return true;       if (($n - $m) * $o > 0 && ($n - $m) % $o == 0)          return true;          return false;    }    $m = 3; $n = 5; $o = 9;    if (contains_val($m, $n, $o))       echo "The number is present in the infinite series";    else       echo "The number is not present in the infinite series"; ?>  Output
The number is not present in the infinite series
Above, three variables are defined, and the function is called by passing these three values −
$m = 3; $n = 5; $o = 9;
A function named ‘contains_val’ is defined, that takes these three variables. The first two variables are compared, and if they are equal, ‘true’ is returned. Otherwise, if the different between the first two variables with the product of the third number is greater than 0 and the different between the first two variables modulus the third number is 0, ‘true’ is returned. Otherwise, the function returns false −
function contains_val($m, $n, $o){    if ($m == $n)       return true;    if (($n - $m) * $o > 0 && ($n - $m) % $o == 0)       return true;    return false; }Advertisements
 