

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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; }
- Related Questions & Answers
- Find if the given number is present in the infinite sequence or not in C++
- Java Program to check if a Float is Infinite or Not a Number(NAN)
- PHP program to check if a number is prime or not
- Check if a given number is sparse or not in C++
- Check if given number is Emirp Number or not in Python
- Check if a number is an Unusual Number or not in C++
- Check if a number is an Achilles number or not in Python
- Check if a number is an Achilles number or not in C++
- C# Program to check if a number is prime or not
- Python program to check if a number is Prime or not
- Check if a number is in given base or not in C++
- PHP program to check if a year is leap year or not
- Check if the given number is Ore number or not in Python
- C program to check if a given string is Keyword or not?
- Python program to check if a given string is Keyword or not
Advertisements