11. Write a PHP script to check if a number is an automorphic number.

Required Input:

25

Expected Output:

true

Code In Php

<?php function isAutomorphic($num) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

12. Create a PHP script to find all prime factors of a given number.

Required Input:

12

Expected Output:

[2,2,3]

Code In Php

<?php function primeFactors($num) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

13. Write a PHP script to implement the Tower of Hanoi algorithm recursively.

Required Input:

3 disks

Expected Output:

Move disk 1 from A to C
Move disk 2 from A to B
Move disk 1 from C to B
Move disk 3 from A to C
Move disk 1 from B to A
Move disk 2 from B to C
Move disk 1 from A to C

Code In Php

<?php function towerOfHanoi($n, $from, $to, $aux) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

14. Create a PHP script to check whether a string contains balanced parentheses.

Required Input:

"(a+b)*(c-d)"

Expected Output:

false

Code In Php

<?php function isBalanced($str) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

15. Write a PHP script to check if a number is a Kaprekar number.

Required Input:

45

Expected Output:

true

Code In Php

<?php function isKaprekar($num) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

16. Create a PHP script to generate all permutations of a given string.

Required Input:

"abc"

Expected Output:

["abc","acb","bac","bca","cba","cab"]

Code In Php

<?php function generatePermutations($str) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

17. Write a PHP script to find the longest palindrome substring in a given string.

Required Input:

babad

Expected Output:

bab

Code In Php

<?php function longestPalindrome($str) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

18. Create a PHP script to compute the sum of the first n natural numbers without using loops.

Required Input:

10

Expected Output:

55

Code In Php

<?php function sumNatural($n) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

19. Write a PHP script to check if an array is sorted in ascending order.

Required Input:

[1, 2, 3, 4]

Expected Output:

true

Code In Php

<?php function isSorted($arr) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

20. Create a PHP script to convert a string to an integer without using intval() or strval().

Required Input:

"123"

Expected Output:

123

Code In Php

<?php function stringToInt($str) { // Your code here } ?>

Run Code?

Click Run Button to view compiled output

ad vertical

2 of 3