0% found this document useful (0 votes)
26 views

PHP - Assignment

The document provides examples and logic for PHP programs to check if a number is a palindrome by reversing its digits and comparing it to the original number. It also gives a Fibonacci series example where each subsequent number is the sum of the previous two numbers, and provides the logic to generate a Fibonacci series by initializing the first two numbers and then adding the previous two numbers in each loop iteration.

Uploaded by

Abdulla Nofal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

PHP - Assignment

The document provides examples and logic for PHP programs to check if a number is a palindrome by reversing its digits and comparing it to the original number. It also gives a Fibonacci series example where each subsequent number is the sum of the previous two numbers, and provides the logic to generate a Fibonacci series by initializing the first two numbers and then adding the previous two numbers in each loop iteration.

Uploaded by

Abdulla Nofal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PHP Programs

1. Write a program to check the given number is a Palindrome or not.

A palindrome number is a number which remains same when its digits


are reversed.

For example, number 24142 is a palindrome number. On reversing it


we’ll get the same number.

Logic:

o Take a number.
o Reverse the input number.
o Compare the two numbers.
o If equal, it means number is palindrome

2. Write a program to generate Fibonacci Series.

Fibonacci series is the one in which you will get your next term by adding
previous two numbers.

For example,

0 1 1 2 3 5 8 13 21 34

Here, 0 + 1 = 1
1+1=2
3 + 2 = 5 and so on.

Logic:

o Initializing first and second number as 0 and 1.


o Print first and second number.
o From next number, start your loop. So third number will be the sum
of the first two numbers.

You might also like