DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP - InversoMoltiplicativo

05.14.2006
| 2730 views |
  • submit to reddit
        // Calcolo degli inversi moltiplicativi

<html>
	<head>
		<title>Calcolo degli inversi moltiplicativi</title>
	</head>

	<body>
		<center>
		<b>Cancolo dell'Inverso Moltiplicativo</b>
		<br><hr><br>
		<table border="1" align="center">
		<?php
			for($i=0; $i<26; $i++)
			{
		?>
			<tr>
		<?php
				for($j=0; $j<26; $j++)
				{
					if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
					else
					if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
					else
					{
						echo "<td align=\"center\">" . $i*$j . "</td>";
						$matrice[$i-1][$j-1] = $i*$j;
					}
				}
		?>
			</tr>
		<?php
			}

			for($i=0; $i<25; $i++)
				for($j=0; $j<25; $j++)
					$matrice[$i][$j] = $matrice[$i][$j]%26;
		?>
		</table>
		<br><hr>
		<b>Tabella dell'Inverso Moltiplicativo</b>
		<br><hr><br>
		<table border="1" align="center">
		<?php
			for($i=0; $i<26; $i++)
			{
				echo "<tr>";
				
				for($j=0; $j<26; $j++)
				{
					if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
					else
					if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
					else
					{
						echo "<td align=\"center\" " . (($matrice[$i-1][$j-1] == 1)?"bgcolor=\"red\"":"") . "\">" . $matrice[$i-1][$j-1] . "</td>";
						
						if($matrice[$i-1][$j-1] == 1)
							$np[] = $i;
					}
				}

				echo "</tr>";
			}
		?>
		</table>
		<br>
		<i><b>I numeri primi con 26 sono:
		<?php
			for($i=0; $i<count($np); $i++)
				echo $np[$i] . " ";
		?>
		</b></i>
		<br><br>
		Si prendono le coppie di numeri che contengono il numero 1 al loro interno, esempio (1,1), (3,9)......
		</center>
	</body>
</html>