PHP form creation

Asked

Viewed 78 times

-1

I am very doubtful about the subject this year that is being PHP, and this activity:

3) Create a PHP form that shows even numbers between 400 and 545
activity photo

It’s something quite simple, according to my teacher, but I’m having a hard time solving it, if someone can give me a boost I’d be happy. Hugs

  • This question is similar to this: https://answall.com/questions/110925/par-ou-%C3%Admpar-de-um-array-em-php

  • Make a loop that starts with the 400 and ends with 545, divide the current number by 2, check the operation module and show the result. PHP Operators

1 answer

2

A solution to this problem would be as follows::

<?php 
for ($x =400; $x<=545; $x++){
    if ($x % 2 == 0){
        echo $x . "<br>";
    }
}
?>
  • 1

    If you only want even numbers and already start from the 400 (which is even), it is not easier to jump 2 in 2? -> for ($x =400; $x<=545; $x += 2) - so it doesn’t even need the if :-)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.