- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 find the first natural number whose factorial can be divided by a number ‘x’
To find the first natural number whose factorial can be divided by a number ‘x’, the code is as follows −
Example
<?php function factorial_num($x_val) { $i = 1; $fact_num = 4; for ($i = 1; $i < $x_val; $i++) { $fact_num = $fact_num * $i; if ($fact_num % $x_val == 0) break; } return $i; } $x_val = 16; print_r("The first natural number whose factorial can be divided by 16 is "); echo(factorial_num($x_val)); ?>
Output
The first natural number whose factorial can be divided by 16 is 4
A function named ‘factorial_num’ computes factorial of a number and checks to see if it is divisible by 16, and if yes, returns that number as output. Outside the function, a number is defined and it is passed as parameter to the function. Relevant output is displayed on the console.
- Related Articles
- Find the first natural number whose factorial is divisible by x in C++
- PHP program to find the sum of first n natural numbers that are divisible by a number ‘x’ or a number ‘y’
- C++ program to find first digit in factorial of a number
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- Find the smallest number by which 1152 must be divided so that it becomes a perfect square. Also find the number whose square is the resulting number.
- Swift Program to Find Factorial of a number
- Java Program to Find Factorial of a number
- Kotlin Program to Find Factorial of a number
- Python program to find factorial of a large number
- PHP program to find the sum of the first n natural numbers who are not powers of a specific number ‘k’
- Python Program to find the factorial of a number without recursion
- Find a natural number whose square diminished by 84 is equal to thrice of 8 more than the given number.
- Can a rational no. be called natural number?
- C++ Program to Find Factorial of a Number using Iteration

Advertisements