VanessaShopping

Non-Repeating Digits

Jan 25th, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: VanessaShopping
  5.  * Date: 25-Jan-17
  6.  * Time: 8:15 PM
  7.  */
  8.  
  9. $n = 45;
  10. $num = NULL;
  11.  
  12. for ($a = 1; $a <= $n; $a++){
  13.     if ($n<102){
  14.         echo "no";
  15.         break;
  16.     }
  17.     for ($b = 0; $b <= 9; $b++){
  18.         for ($c = 0; $c <= 9; $c++){
  19.             if ($a!=$b && $a!=$c && $b!=$c){
  20.                 $num = (int)$a.$b.$c;
  21.                 if ($num<=$n){
  22.                     echo $num . "\n";
  23.                 }
  24.                 else{
  25.                     break 3;
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment