Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Numeros randomicos!
- * @param min e max
- * @author Henrique Silva
- */
- $number_rand = rand(1, 100);
- /**
- * Array para armazenar os divisores
- */
- $divisores = [];
- /**
- * Loop para armazenar os divisores
- */
- for($i=1; $i <= $number_rand; $i++){
- $result_div = $number_rand / $i;
- if(is_int($result_div)){
- $divisores[] = $result_div;
- }
- }
- /**
- * Verificar si o numero é dividido apenas por 2 divisores!
- */
- if(count($divisores) == 2){
- echo "O numero {$number_rand} é primo!";
- }else{
- echo "O numero {$number_rand} não é primo!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement