-
Lenguaje
PHP
-
Descripción
Determinar si un número es múltiplo de 2, de 3, de 5 o de ninguno de ellos. Considere que existen números que pueden ser múltiplos de más de un número. Por ejemplo: si se ingresa 15 debe mostrarse "El número es múltiplo de 3", "El número es múltiplo de 5".
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Múltiplo de 2, 3 o 5</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
<html>
<head>
<title>Múltiplo de 2, 3 o 5</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
if ($_SERVER['REQUEST_METHOD']=='POST')
{
$numero = intval ($_POST['numero']);
if($numero%2==0)
echo 'El número es múltiplo de 2.<br>'
if($numero%3==0)
echo 'El número es múltiplo de 3.<br>'
if($numero%5==0)
echo 'El número es múltiplo de 5.<br>'
if($numero%2!=0&&$numero%3!=0)
echo 'No es múltiplo de ninguno de ellos.<br>'
}
<form method="post">
<table style="text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td>
<label for="numero">Ingresa el valor de numero:</label>
</td>
<td>
<input name="numero" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="submit" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
<table style="text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td>
<label for="numero">Ingresa el valor de numero:</label>
</td>
<td>
<input name="numero" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="submit" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>