PHP - InversoMoltiplicativo


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <html>
  2. <head>
  3. <title>Calcolo degli inversi moltiplicativi</title>
  4. </head>
  5.  
  6. <body>
  7. <center>
  8. <b>Cancolo dell'Inverso Moltiplicativo</b>
  9. <br><hr><br>
  10. <table border="1" align="center">
  11. <?php
  12. for($i=0; $i<26; $i++)
  13. {
  14. ?>
  15. <tr>
  16. <?php
  17. for($j=0; $j<26; $j++)
  18. {
  19. if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
  20. else
  21. if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
  22. else
  23. {
  24. echo "<td align=\"center\">" . $i*$j . "</td>";
  25. $matrice[$i-1][$j-1] = $i*$j;
  26. }
  27. }
  28. ?>
  29. </tr>
  30. <?php
  31. }
  32.  
  33. for($i=0; $i<25; $i++)
  34. for($j=0; $j<25; $j++)
  35. $matrice[$i][$j] = $matrice[$i][$j]%26;
  36. ?>
  37. </table>
  38. <br><hr>
  39. <b>Tabella dell'Inverso Moltiplicativo</b>
  40. <br><hr><br>
  41. <table border="1" align="center">
  42. <?php
  43. for($i=0; $i<26; $i++)
  44. {
  45. echo "<tr>";
  46.  
  47. for($j=0; $j<26; $j++)
  48. {
  49. if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
  50. else
  51. if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
  52. else
  53. {
  54. echo "<td align=\"center\" " . (($matrice[$i-1][$j-1] == 1)?"bgcolor=\"red\"":"") . "\">" . $matrice[$i-1][$j-1] . "</td>";
  55.  
  56. if($matrice[$i-1][$j-1] == 1)
  57. $np[] = $i;
  58. }
  59. }
  60.  
  61. echo "</tr>";
  62. }
  63. ?>
  64. </table>
  65. <br>
  66. <i><b>I numeri primi con 26 sono:
  67. <?php
  68. for($i=0; $i<count($np); $i++)
  69. echo $np[$i] . " ";
  70. ?>
  71. </b></i>
  72. <br><br>
  73. Si prendono le coppie di numeri che contengono il numero 1 al loro interno, esempio (1,1), (3,9)......
  74. </center>
  75. </body>
  76. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.