Just simply print this series

Asked By 10 points N/A Posted on -

hello i am php programmer and  i want to print one number series which could be start from any number and end to any number for example if i take 1-10 then my series should be like











but keep in mind that the number can be of any limit like it could be 1 to 1000 or any number of limit..

this is really so simple to print but we have some restrictions here

1. we need to use for loop only.

2. we cannot use like i+1 or 1+2 ,3 simple i++ in for loop for increment

3. we cannot use any if condition. or any other condition

4 we cannot create any another function  to check the codition

5. we cannot use multiplication and division in it.

6. one more think that the series should be in array and we cannot define the array number like array(1,2,3,4,) no, only we need to use some other method from which i will only enter starting and end limit and that will return us the array. we can use inbuilt functions.

we need to follow each and every point of restriction else this will not setisfice the condition… we can print this by other methods too but need to follow all restriction..

Best Answer by Shifflett Laurel
Answered By 0 points N/A #85226

Just simply print this series


kindly use the following code to print the series :



<form action="welcome2.php" method="get">
Enter minimum number: <input type="text" name="min" />
Enter maximum number: <input type="text" name="max" />
<input type="submit" />
$min = $_GET["min"];
$max = $_GET["max"];
$arr[0] = $min;
for($i = 1;$i <= $max-$min; $i++)
$j = rand($min+1, $max);
 $j = rand($min+1, $max);
  $arr[$i] = $j;
for($i = 0;$i <= $max-$min +1; $i++)
echo $arr[$i]."<br>";
Best Answer
Best Answer
Answered By 0 points N/A #197084

Just simply print this series


Hellow Test_demo,

You can use the following code for printing a range of numbers.


$safa=5; // Declare a variable for first value of the range

$saad=3000000; //Declare another variable last value of the range

$range=range($safa,$saad); //Using a range function declared by a variable range

printf($range); // Call the function to print the desired range of numbers


Another example using foreach and range:


foreach(range(1,10) as $num

{ printf("100 x $num=").(100 * $num) ."n";




Shifflett Laurel

Login/Register to Answer

Related Questions