Generate Monday Numbers

35

6

Monday numbers, as defined by Gamow in this question over on Puzzling, are positive integers N with the following three properties:

  • The decimal representation of N does not contain the digit 0
  • The decimal representation of N does not contain any digit twice
  • N is divisible by every digit D that occurs in its decimal representation

Note that these are alternatively known, in the OEIS, as Lynch-Bell numbers.

Examples:

  • 15 is a Monday number, as it's divisible by both 1 and 5 and satisfies the other two conditions
  • 16 is not, because it's not divisible by 6.
  • The number 22 is not, because though it satisfies conditions 1 and 3, it fails condition 2.

Here's the list of the first 25 Monday numbers to get you started (there are 548 total):

1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248

The challenge here is to write the shortest code that generates the full sequence of Monday numbers, from 1 up to 9867312 (proven on that question to be the largest possible).

Your code should take no input, and output should be to STDOUT or equivalent, with your choice of delimiter. All the usual code-golf rules apply, and Standard Loopholes are prohibited.

Leaderboard

var QUESTION_ID=59014,OVERRIDE_USER=42963;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

AdmBorkBork

Posted 2015-09-29T14:51:44.130

Reputation: 41 581

5Related – FryAmTheEggman – 2015-09-29T15:03:31.753

1

Also known as Lynch-Bell numbers.

– Geobits – 2015-09-29T15:21:13.013

@Geobits Thanks - I couldn't find it on OEIS for some reason. – AdmBorkBork – 2015-09-29T15:23:27.650

Do they have to be generated in numerical order? – Glen O – 2015-09-29T15:34:11.563

@GlenO No, I suppose there's no restriction on that. – AdmBorkBork – 2015-09-29T15:36:01.290

8You should have posted this challenge yesterday... – mbomb007 – 2015-09-29T16:42:15.597

2@mbomb007 I would have - didn't see Gamow's question until this morning, though! – AdmBorkBork – 2015-09-29T16:44:13.523

Answers

1

Jelly, 8 bytes

ȷ7Dg⁼QƲƇ

Runs locally in under eight minutes.

Try it online! (modified to find numbers with six digits or less)

How it works

ȷ7Dg⁼QƲƇ  Main link. No arguments.

ȷ7        Set the return value to 10**7.
       Ƈ  Comb; promote 10**7 to [1, ..., 10**7], then keep only those n in the range
          for which the link to the left returns a truthy value.
      Ʋ     Combine the four links to the left into a monadic chain.
  D           Decimal; yield n's digit array in base 10.
   g          Take the GCD of each digit and n.
     Q        Yield the unique digits of n.
    ⁼         Test both results for equality.

Dennis

Posted 2015-09-29T14:51:44.130

Reputation: 196 637

16

Python 2, 85 bytes

print[n for n in range(1,9**9)if(n<10**len(set(`n`)))>any(n%(int(d)or.3)for d in`n`)]

Prints a list.

I'm basically combining two of my answers to previous challenges:

Thanks to xsot for 1 byte saved by combining the conditions better.

xnor

Posted 2015-09-29T14:51:44.130

Reputation: 115 687

You can save a byte: print[n for n in range(1,9**9)if(n<10**len(set(\n`)))>any(n%(int(d)or.3)for d in`n`)]` – xsot – 2015-09-29T23:33:57.213

11

Perl, 61 47 bytes

46 bytes code + 1 byte command line parameter.

/(.).*\1|0/||1*s/./$_%$&/rge||print for 1..1e7

Usage:

perl -l entry.pl

Explanation

/(.).*\1|0/ returns 1 if the number-under-test contains a duplicate character or a 0

s/./$_%$&/rge replaces each digit with the value of the number-under-test % the digit. For example, 15 -> 00, 16 -> 04 (because 16%6=4). This means that any input which is divisible by all of its digits will consist of all 0s, otherwise it will contain a digit >0. In order to treat this as a number, we *1, which means any number-under-test will return 0 for this block if it is divisible by all of its digits, otherwise >0.

By separating these two statements and the print with 'or's, if either of the first two conditions returns >0, the condition matches and the subsequent parts of the expression will not evaluate. If and only if both previous conditions are 0, the print will then execute. The -l flag ensures to add a new line after each print.

Jarmex

Posted 2015-09-29T14:51:44.130

Reputation: 2 045

Very nice. You can save a few bytes by making it Perl 5.10 and using say instead of print + -l :-)

– xebtl – 2015-09-30T13:21:25.553

Thanks for the suggestion! I thought say required an explicit declaration first?

– Jarmex – 2015-09-30T20:41:07.613

@Jarmex I may have started the tradition around here of taking use feature 'say' or use 5.012 for free — I always mention when I do it, and no one has ever challenged it. I've seen a few others do the same :) – hobbs – 2015-10-01T05:45:13.447

2

@hobbs This answer on meta says “The consensus up to now on SO and here was "the -M5.010, when needed, is free"”.

– xebtl – 2015-10-01T08:13:16.620

2

Using map and say gets this down to 43: Try it online!

– Xcali – 2018-05-09T05:11:49.397

10

Pyth, 22 21

f&.{`T!f%T|vY.3`TS^T7

Thanks to Jakube for golfing off 1 byte of unnecessary formatting.

Heavily inspired by this CW answer to the related question.

I have a paste of the result here, from when it printed newline separated, now it prints as a pythonic list.

I would recommend not trying it online unless you use a number smaller than 7... I've set it to 2 in this link.

Filters from 1 to 10^7-1 which covers all the necessary values. This version may cause a memory error if it cannot make the list S^T7, which is similar to list(range(1,10**7)) in python 3 (However, it works fine for me). If so, you could try:

.f&.{`Z.x!s%LZjZT0548

Which finds the first 548 Monday numbers. This also demonstrates another way to check for the 0s in the number, instead of replacing them with .3 this uses a try-catch block. Credit for this version goes entirely to Jakube. (Note that this is still much to slow for the online interpreter)

FryAmTheEggman

Posted 2015-09-29T14:51:44.130

Reputation: 16 206

1Here's a different solution: .f&.{`Z.x!s%LZjZT0548 It's quite a bit times faster (4x - 5x) than your while-loop approach and has also only 21 bytes in length. – Jakube – 2015-09-29T18:29:11.540

1@Jakube Backticks are a pain in comments aren't they? :P Thanks a lot though! – FryAmTheEggman – 2015-09-29T18:30:35.280

Umm.. your solution doesn't seem to work.. In your TIO link in the range to 100, it shows 55, 66, 77, 88, 99, all numbers with duplicated digits.. – Kevin Cruijssen – 2018-05-10T17:25:29.020

1@KevinCruijssen Unfortunately, Pyth has been updated so many times since I made this post, I can't find what has changed. You can see in the paste that this clearly did work before. I think it might be .{ having been changed, since replacing it with {I seems to work. – FryAmTheEggman – 2018-05-10T20:52:57.213

@FryAmTheEggman Ah, I hadn't seen the paste. It's indeed been almost three years, so no wonder things might have changed. +1 in that case, because the paste proves it worked. :) – Kevin Cruijssen – 2018-05-10T21:04:11.757

9

GS2, 20 19 bytes

gs2 uses a wide range of bytes, not just printable ascii chracters. I will present my solution in hex.

17 7d 2f 24 65 f1 c8 24 d8 62 e9 65 f4 24 40 90 71 f3 54

Here's some explanation. gs2 is a stack based language, so there are no variables. (aside from 4 registers, one of which i use here)

17         # push constant 7
7d         # 10 raised to the power
2f         # create an array of numbers from 1 to n

    24     # get digits of number into array
    65     # calculate product of array
f1         # filter array by previous block of 2 instructions

    c8     # save top of stack to register a
    24     # get digits of number into array
        d8 # tuck register a under top of stack
        62 # boolean divisibility test 
    e9     # map array using previous block of 2 instructions
    65     # calculate product of array
f4         # filter array by previous block of 5 instructions 

    24     # get digits of number into array
    40     # duplicate top of stack
    90     # remove duplicates from array
    71     # test equality
f3         # filter array by previous block of 4 instructions
54         # show contents of array separated by line breaks

recursive

Posted 2015-09-29T14:51:44.130

Reputation: 8 616

8

Python 3, 132 128 114 111 104 bytes

i=0
while i<1e8:
 j=str(i)
 if len(set(j))+2==len(j)+('0'in j)+all(i%int(k)<1 for k in j):print(i)
 i+=1

There are 548 Monday Numbers.

Zach Gates

Posted 2015-09-29T14:51:44.130

Reputation: 6 152

1Could you use 1e8 instead of even 9**9? – Dom Hastings – 2015-09-29T15:23:22.390

Remove the space in '0' not. Also, i%int(k)==0 can probably be i%int(k)<1? – mbomb007 – 2015-09-29T16:43:07.800

Thanks. I didn't mean to add that back in. @mbomb007 – Zach Gates – 2015-09-29T16:43:48.310

You can use j=\i``. – mbomb007 – 2015-09-29T16:47:19.870

For another -6 use if len(set(j))+2==len(j)+('0'in j)+all(i%int(k)<1 for k in j) – lirtosiast – 2015-09-29T20:03:17.663

7

APL, 44 39 37 bytes

{0=+/(⊢|∘⍵,0∘∊,⍴∘⊢≠⍴∘∪)⍎¨⍕⍵:⍵⋄⍬}¨⍳1e7

Ungolfed:

{
 x ← ⍎¨⍕⍵⋄                    ⍝ Define x to be a vector of the digits of ⍵
 0=+/(⊢|∘⍵,0∘∊,⍴∘⊢≠⍴∘∪)x:   ⍝ No zeros, all digits divide ⍵, all unique?
 ⍵⋄⍬                          ⍝ If so, return the input, otherwise null
}¨⍳1e7                        ⍝ Apply to the integers 1..1E7

Saved 7 bytes thanks to Moris Zucca!

Alex A.

Posted 2015-09-29T14:51:44.130

Reputation: 23 761

I love APL. This is why. – Conor O'Brien – 2015-09-30T01:07:20.863

I think you can golf it using function trains, saving 5 bytes: {0=+/(⊢|∘⍵,0∘∊,⍴∘⊢≠⍴∘∪)x←⍎¨⍕⍵:⍵⋄⍬}¨⍳1e7 – Moris Zucca – 2015-09-30T13:59:27.370

@MorisZucca Awesome, thanks for the suggestion! – Alex A. – 2015-10-01T19:41:57.737

I just saw that in this form x← is not needed any more, so 2 more bytes saved! :-) – Moris Zucca – 2015-10-02T07:57:47.660

@MorisZucca You're an APL golfing machine! Thanks again! – Alex A. – 2015-10-02T18:26:31.163

6

TI-BASIC, 60 59 bytes

For(X,1,ᴇ7
int(10fPart(X10^(-randIntNoRep(1,1+int(log(X->D
SortA(∟D
If X>9
If not(max(remainder(X,Ans+2Xnot(Ansmin(ΔList(∟D
Disp X
End

∟D is the list of digits, which is generated using math and the randIntNoRep( command (random permutation of all integers between 1 and 1+int(log(X inclusive). I use a slightly complicated chain of statements to check if all of the conditions are satisfied:

   min(ΔList(∟D        ;Zero if repeated digit, since ∟D was sorted ascending
Ans                    ;Multiplies the unsorted copy of ∟D by the minimum from above
                       ;(Lists are different dimensions; we can't elementwise AND)
                       ;Will contain a 0 if there's a 0 digit or a repeated digit
      not(             ;If there's a zero,
Ans+2X                 ;Add 2X to that pos. in the list, failing the test:

    max(remainder(X,   ;Zero iff all digits divide X and 2X wasn't added
not(

To fail numbers that have repeated digits or zero digits, I replace zeroes with 2X, because X is never divisible by 2X.

To special-case 1~9 (because ΔList( on a one-element list errors) I use the If statement in the fourth line to skip over the check in the fifth line, automatically displaying all X≤9.

The output numbers are separated by newlines.

lirtosiast

Posted 2015-09-29T14:51:44.130

Reputation: 20 331

5

Mathematica 105

l=Length;Cases[Range@9867312,n_ /;(FreeQ[i=IntegerDigits@n,0]&&l@i== l@Union@i&&And@@(Divisible[n,#]&/@i))]
  • IntegerDigits breaks up n into a list of its digits, i.
  • FreeQ[i,0] checks whether there are no zeros in the list.
  • Length[i]==Length[Union[i]] checks that there are no repeated digits.
  • And@@(Divisible[n,#]&/@i) checks that each digit is a divisor of n.

{1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 24, 36, 48, 124, 126, 128, 132, 135, 162, 168, 175, 184, 216, 248, 264, 312, 315, 324, 384, 396, 412, 432, 612, 624, 648, 672, 728, 735, 784, 816, 824, 864, 936, 1236, 1248, 1296, 1326, 1362, 1368, 1395, 1632, 1692, 1764, 1824, 1926, 1935, 1962, 2136, 2184, 2196, 2316, 2364, 2436, 2916, 3126, 3162, 3168, 3195, 3216, 3264, 3276, 3492, 3612, 3624, 3648, 3816, 3864, 3915, 3924, 4128, 4172, 4236, 4368, 4392, 4632, 4872, 4896, 4932, 4968, 6132, 6192, 6312, 6324, 6384, 6432, 6912, 6984, 8136, 8496, 8736, 9126, 9135, 9162, 9216, 9315, 9324, 9432, 9612, 9648, 9864, 12384, 12648, 12768, 12864, 13248, 13824, 13896, 13968, 14328, 14728, 14832, 16248, 16824, 17248, 18264, 18432, 18624, 18936, 19368, 21384, 21648, 21784, 21864, 23184, 24168, 24816, 26184, 27384, 28416, 29736, 31248, 31824, 31896, 31968, 32184, 34128, 36792, 37128, 37296, 37926, 38472, 39168, 39816, 41328, 41832, 42168, 42816, 43128, 43176, 46128, 46872, 48216, 48312, 61248, 61824, 62184, 64128, 68712, 72184, 73164, 73248, 73416, 73962, 78624, 79128, 79632, 81264, 81432, 81624, 81936, 82416, 84216, 84312, 84672, 87192, 89136, 89712, 91368, 91476, 91728, 92736, 93168, 93816, 98136, 123648, 123864, 123984, 124368, 126384, 129384, 132648, 132864, 132984, 134928, 136248, 136824, 138264, 138624, 139248, 139824, 142368, 143928, 146328, 146832, 148392, 148632, 149328, 149832, 162384, 163248, 163824, 164328, 164832, 167328, 167832, 168432, 172368, 183264, 183624, 184392, 184632, 186432, 189432, 192384, 193248, 193824, 194328, 194832, 198432, 213648, 213864, 213984, 214368, 216384, 218736, 219384, 231648, 231864, 231984, 234168, 234816, 236184, 238416, 239184, 241368, 243168, 243768, 243816, 247968, 248136, 248976, 261384, 263184, 273168, 281736, 283416, 284136, 291384, 293184, 297864, 312648, 312864, 312984, 314928, 316248, 316824, 318264, 318624, 319248, 319824, 321648, 321864, 321984, 324168, 324816, 326184, 328416, 329184, 341928, 342168, 342816, 346128, 348192, 348216, 348912, 349128, 361248, 361824, 361872, 362184, 364128, 364728, 367248, 376824, 381264, 381624, 382416, 384192, 384216, 384912, 391248, 391824, 392184, 394128, 412368, 413928, 416328, 416832, 418392, 418632, 419328, 419832, 421368, 423168, 423816, 427896, 428136, 428736, 431928, 432168, 432768, 432816, 436128, 438192, 438216, 438912, 439128, 461328, 461832, 463128, 468312, 469728, 478296, 478632, 481392, 481632, 482136, 483192, 483216, 483672, 483912, 486312, 489312, 491328, 491832, 493128, 498312, 612384, 613248, 613824, 613872, 614328, 614832, 618432, 621384, 623184, 623784, 627984, 631248, 631824, 632184, 634128, 634872, 641328, 641832, 643128, 648312, 671328, 671832, 681432, 684312, 689472, 732648, 732816, 742896, 746928, 762384, 768432, 783216, 789264, 796824, 813264, 813624, 814392, 814632, 816432, 819432, 823416, 824136, 824376, 831264, 831624, 832416, 834192, 834216, 834912, 836472, 841392, 841632, 842136, 843192, 843216, 843912, 846312, 849312, 861432, 864312, 873264, 891432, 894312, 897624, 912384, 913248, 913824, 914328, 914832, 918432, 921384, 923184, 927864, 931248, 931824, 932184, 934128, 941328, 941832, 943128, 948312, 976248, 978264, 981432, 984312, 1289736, 1293768, 1369872, 1372896, 1376928, 1382976, 1679328, 1679832, 1687392, 1738296, 1823976, 1863792, 1876392, 1923768, 1936872, 1982736, 2137968, 2138976, 2189376, 2317896, 2789136, 2793168, 2819376, 2831976, 2931768, 2937816, 2978136, 2983176, 3186792, 3187296, 3196872, 3271968, 3297168, 3298176, 3619728, 3678192, 3712968, 3768912, 3796128, 3816792, 3817296, 3867192, 3869712, 3927168, 3928176, 6139728, 6379128, 6387192, 6389712, 6391728, 6719328, 6719832, 6731928, 6893712, 6913872, 6971328, 6971832, 7168392, 7198632, 7231896, 7291368, 7329168, 7361928, 7392168, 7398216, 7613928, 7639128, 7829136, 7836192, 7839216, 7861392, 7863912, 7891632, 7892136, 7916328, 7916832, 7921368, 8123976, 8163792, 8176392, 8219736, 8312976, 8367912, 8617392, 8731296, 8796312, 8912736, 8973216, 9163728, 9176328, 9176832, 9182376, 9231768, 9237816, 9278136, 9283176, 9617328, 9617832, 9678312, 9718632, 9723168, 9781632, 9782136, 9812376, 9867312}

Length[%]

548

DavidC

Posted 2015-09-29T14:51:44.130

Reputation: 24 524

I expect there is a way in mathematica to get large numbers in fewer bytes, like 9^9 or 1e8 or something – FryAmTheEggman – 2015-09-29T15:30:16.000

I'm surprised Mathematica doesn't have a built-in for this ;-). Nice trick with the Union to check for duplicates. – AdmBorkBork – 2015-09-29T15:48:06.680

@FryAmTheEggman, You are correct about Mathematica allowing for 9^9. But wouldn't that return more than 548 Monday numbers? – DavidC – 2015-09-29T16:27:47.227

As said in the question, there is no possible Monday number greater than the one given as the upper limit. – FryAmTheEggman – 2015-09-29T16:28:41.957

5

Haskell, 77 bytes

[x|x<-[1..9^9],all(\a->a>'0'&&mod x(read[a])+sum[1|y<-show x,y==a]<2)$show x]

Usage example (the first 20 numbers):

take 20 $ [x|x<-[1..9^9],all(\a->a>'0'&&mod x(read[a])+sum[1|y<-show x,y==a]<2)$show x]

[1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162]

How it works: iterate over all numbers from 1 to 9^9 and check the conditions. The current number x is turned into it's string representation (show x) to operate on it as a list of characters.

nimi

Posted 2015-09-29T14:51:44.130

Reputation: 34 639

5

R, 99 bytes

for(n in 1:1e8){i=1:nchar(n);if(all(table(d<-(n%%10^i)%/%10^(i-1))<2)&!0%in%d&all(!n%%d))cat(n,"")}

Slightly less golfed:

for(n in 1:1e8){
    i = 1:nchar(n)
    d = (n%%10^i)%/%10^(i-1) # Digits of n
    if(all(table(d)<2) # No digits is present more than once 
      & !0%in%d        # 0 is not one of the digits
      & all(!n%%d))    # All digits are divisors of n
    cat(n,"")
    }

plannapus

Posted 2015-09-29T14:51:44.130

Reputation: 8 610

5

Perl, 90 75 70 bytes

print+($_,$/)x(grep(!/(\d).*\1|0/,$_)&s/./!$&||$_%$&/ger<1)for 1..1e7

steve

Posted 2015-09-29T14:51:44.130

Reputation: 2 276

1Ahhh, I missed the \1 trick for dupe checking, nice. Can you save more with a statement modifier while and a ternary print? – Dom Hastings – 2015-09-30T20:17:57.437

@DomHastings thanks, now more golfed using your suggestion – steve – 2015-09-30T21:11:17.773

Nice, I think you can save a few more as well, as you don't need the ^ and the $ around the 0 in your grep, you can replace the && before s/./ with a single & and I think the last |0 is unneeded (although only tested up-to 1e3...). Well and truly thrashed my score! :) – Dom Hastings – 2015-10-01T04:48:46.563

1@DomHastings thanks, down to 70 with your golfing tips. – steve – 2015-10-01T07:03:44.523

Golfed it down a bit more by getting rid of the grep (unnecessary--the pattern match takes care of it without grep) and rearranging the rest into a map: Try it online!

– Xcali – 2019-01-03T16:57:25.940

4

05AB1E, 30 22 21 18 14 13 12 9 bytes

-9 byte thanks to the help and encouragement of @Enigma and @Mr.Xcoder. Thanks for letting me mostly figure it out myself, even though you already had a 12-byte solution in mind when I was still at 30. Learned a lot about 05AB1E from this challenge!
-3 bytes thanks to @Grimy

7°LʒÐÑÃÙQ

Try it online (only outputs the numbers below 103 instead of 107 to prevent a timeout after 60 sec).

Explanation:

7°L        # Generate a list in the range [1, 10^7]
   ʒ       # Filter, so only the numbers that evaluated to 1 (truthy) remain:
    Ð      #  Triplicate the current number
     Ñ     #  Get the divisors of this number
           #   i.e. 128 → [1,2,4,8,16,32,64,128]
           #   i.e. 1210 → [1,2,5,10,11,22,55,110,121,242,605,1210]
      Ã    #  Only keep those digits/numbers in the original number (which is checked in
           #  order, so it will only keep the digits and ignores the later numbers)
           #   i.e. 128 → 128
           #   i.e. 1210 → 121
       Ù   #  Uniquify the number, removing any duplicated digits
           #   i.e. 128 → 128
           #   i.e. 121 → 12
        Q  #  Check if the number is unchanged after this
           #   i.e. 128 and 128 → 1 (truthy)
           #   i.e. 1210 and 12 → 0 (falsey)

Previous 12 byter version (one of my very first 05AB1E answers):
NOTE: Only works in the legacy version of 05AB1E.

7°LʒÐSÖPsDÙQ*

Try it online (only outputs the numbers below 103 instead of 107 to prevent a timeout after 60 sec).

Explanation:

7°L        # Generate a list in the range [1, 10^7]
   ʒ       # Filter, so only the numbers that evaluated to 1 (true) remain:
    Ð      #  Triplicate the current number N
     Ù     #  Remove all duplicated digits of the second N
           #   i.e. 1210 → 120
      Q    #  Check if the last two numbers are still the same (1 or 0 as result)
    *      #  Multiply this result with remaining third number from the triplication
     D     #  Duplicate this number, so we have two again
      S    #  Separate all the digits of the second one
           #   i.e. 128 → ['1', '2', '8']
       Ö   #  Check if (the second) N is divisible by each of its digits
           #   i.e. 128 and ['1', '2', '8'] → [1, 1, 1]
           #   (NOTE: If the number contains a '0', it won't error on division by 0,
           #          but instead return the number N itself in the list)
           #   i.e. 105 and ['1', '0', '5'] → [1, 105, 1]
        P  #  Take the product of this list (if the divisible test for one
           #  of the digits was 0, this will be 0 as well)
           #   i.e. [1, 1, 1] → 1
           #   i.e. [1, 105, 1] → 105 (only 1 is truthy in 05AB1E)

Kevin Cruijssen

Posted 2015-09-29T14:51:44.130

Reputation: 67 575

Your answer prints 297, which is not in the sequence of Lynch-Bell numbers. – Mr. Xcoder – 2018-05-09T13:25:01.417

@Mr.Xcoder Sigh.. Had something longer at first for checking if a number is divisible by all its digits, but figured a challenge like that existed. It seems this answer is therefore also invalid.. And here you and Enigma are talking about 12-15 byte answers while my 30-byte answer doesn't even work, lol.. Is there a tutorial anywhere? ;p

– Kevin Cruijssen – 2018-05-09T13:33:09.507

19 bytes: 7°LʒÐÑÃÙQ – Grimmy – 2019-05-07T13:56:23.833

@Grimy One of my very first 05AB1E answers. :) Nice approach! – Kevin Cruijssen – 2019-05-07T14:16:25.090

4

CJam, 25 bytes

1e7{_Ab__&0-_@=@@f%1b>},`

Try it online. Note that online link only runs to 10,000. I'm not sure if it would finish online if you're patient enough. It haven't tested it with the offline version of CJam, but I expect that it would terminate.

Explanation:

1e7     Upper limit.
{       Start filter loop.
  _Ab     Copy and convert to list of decimal digits.
  __&     Intersect list with itself to remove duplicates.
  0-      Remove zero.
  _       Make a copy of unique non-zero digits. Will use these as divisors.
  @=      Compare unique non-zero digits to all digits. Must be true for Monday numbers.
  @@      Rotate original number and list of non-zero digits to top.
  f%      Remainders of original number with all non-zero digits.
  1b      Sum up the remainders. Since they all must be zero for Monday numbers,
          their sum must be zero.
  >       Check that first part of condition was 1, and sum of remainders 0.
},      End filter loop.
`       Convert resulting list to string.

Reto Koradi

Posted 2015-09-29T14:51:44.130

Reputation: 4 870

4

C#, 230 227

It's been a while since I've golved so I probably forgot a few tricks to get the bytecount down. Will improve when I think of them... For now:

using System.Linq;class P{static void Main(){System.Console.Write(string.Join(",",Enumerable.Range(0,1<<24).Where(i=>{var s=i.ToString();return!s.Contains('0')&&s.Length==s.Distinct().Count()&&s.All(x=>i%(48-(int)x)==0);})));}}

Ungolfed:

using System.Linq;
class P
{
    static void Main()
    {
        System.Console.Write(                                       //Output...
            string.Join(                                            //...all results...
                ",",                                                //...comma separated...
                Enumerable.Range(0, 1<<24)                          //...from 0 to 16777216...
                    .Where(i => {                                   //...where...
                        var s = i.ToString();                       //...the digits as char array (what we usually call a string)...
                        return !s.Contains('0')                     //...for which none of the digits is 0...
                            && s.Length == s.Distinct().Count()     //...and the number of distinct digits equals the total number of digits (e.g. all unique)...
                            && s.All(x => i % (48 - (int)x) == 0);  //...and the number is divisible by each of the digits (after 'ASCII-correction')
                    })
            )
        );
    }
}

1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162,168,175,184,216,248,264,312,315,324,384,396,412,432,612,624,648,672,728,735,784,816,824,864,936,1236,1248,1296,1326,1362,1368,1395,1632,1692,1764,1824,1926,1935,1962,2136,2184,2196,2316,2364,2436,2916,3126,3162,3168,3195,3216,3264,3276,3492,3612,3624,3648,3816,3864,3915,3924,4128,4172,4236,4368,4392,4632,4872,4896,4932,4968,6132,6192,6312,6324,6384,6432,6912,6984,8136,8496,8736,9126,9135,9162,9216,9315,9324,9432,9612,9648,9864,12384,12648,12768,12864,13248,13824,13896,13968,14328,14728,14832,16248,16824,17248,18264,18432,18624,18936,19368,21384,21648,21784,21864,23184,24168,24816,26184,27384,28416,29736,31248,31824,31896,31968,32184,34128,36792,37128,37296,37926,38472,39168,39816,41328,41832,42168,42816,43128,43176,46128,46872,48216,48312,61248,61824,62184,64128,68712,72184,73164,73248,73416,73962,78624,79128,79632,81264,81432,81624,81936,82416,84216,84312,84672,87192,89136,89712,91368,91476,91728,92736,93168,93816,98136,123648,123864,123984,124368,126384,129384,132648,132864,132984,134928,136248,136824,138264,138624,139248,139824,142368,143928,146328,146832,148392,148632,149328,149832,162384,163248,163824,164328,164832,167328,167832,168432,172368,183264,183624,184392,184632,186432,189432,192384,193248,193824,194328,194832,198432,213648,213864,213984,214368,216384,218736,219384,231648,231864,231984,234168,234816,236184,238416,239184,241368,243168,243768,243816,247968,248136,248976,261384,263184,273168,281736,283416,284136,291384,293184,297864,312648,312864,312984,314928,316248,316824,318264,318624,319248,319824,321648,321864,321984,324168,324816,326184,328416,329184,341928,342168,342816,346128,348192,348216,348912,349128,361248,361824,361872,362184,364128,364728,367248,376824,381264,381624,382416,384192,384216,384912,391248,391824,392184,394128,412368,413928,416328,416832,418392,418632,419328,419832,421368,423168,423816,427896,428136,428736,431928,432168,432768,432816,436128,438192,438216,438912,439128,461328,461832,463128,468312,469728,478296,478632,481392,481632,482136,483192,483216,483672,483912,486312,489312,491328,491832,493128,498312,612384,613248,613824,613872,614328,614832,618432,621384,623184,623784,627984,631248,631824,632184,634128,634872,641328,641832,643128,648312,671328,671832,681432,684312,689472,732648,732816,742896,746928,762384,768432,783216,789264,796824,813264,813624,814392,814632,816432,819432,823416,824136,824376,831264,831624,832416,834192,834216,834912,836472,841392,841632,842136,843192,843216,843912,846312,849312,861432,864312,873264,891432,894312,897624,912384,913248,913824,914328,914832,918432,921384,923184,927864,931248,931824,932184,934128,941328,941832,943128,948312,976248,978264,981432,984312,1289736,1293768,1369872,1372896,1376928,1382976,1679328,1679832,1687392,1738296,1823976,1863792,1876392,1923768,1936872,1982736,2137968,2138976,2189376,2317896,2789136,2793168,2819376,2831976,2931768,2937816,2978136,2983176,3186792,3187296,3196872,3271968,3297168,3298176,3619728,3678192,3712968,3768912,3796128,3816792,3817296,3867192,3869712,3927168,3928176,6139728,6379128,6387192,6389712,6391728,6719328,6719832,6731928,6893712,6913872,6971328,6971832,7168392,7198632,7231896,7291368,7329168,7361928,7392168,7398216,7613928,7639128,7829136,7836192,7839216,7861392,7863912,7891632,7892136,7916328,7916832,7921368,8123976,8163792,8176392,8219736,8312976,8367912,8617392,8731296,8796312,8912736,8973216,9163728,9176328,9176832,9182376,9231768,9237816,9278136,9283176,9617328,9617832,9678312,9718632,9723168,9781632,9782136,9812376,9867312

RobIII

Posted 2015-09-29T14:51:44.130

Reputation: 397

can (int)1e7 be 1<<24? – lirtosiast – 2015-10-02T08:52:49.827

@ThomasKwa Yes, it can be. Indeed. Thanks! – RobIII – 2015-10-02T12:08:45.090

4

TI-BASIC, 55 53 bytes

This is a relatively minor edit of Thomas Kwa's answer, but I am submitting it as a new answer because I'd heard that he has put a bounty on golfing his TI-BASIC answers.

For(X,1,ᴇ7
int(10fPart(X10^(-randIntNoRep(0,1+int(log(X->D
SortA(∟D
If not(sum(remainder(X,Ans+Xnot(Ansmin(ΔList(∟D
Disp X
End

My main change is from randIntNoRep(1, to randIntNoRep(0, meaning that there will now a zero in every generated list of digits.

number  |  randIntNoRep  |  digits  |  sorted
9       |  1,0           |  9,0     |  0,9
102     |  3,1,0,2       |  1,2,0,0 |  0,0,1,2

Since there's now a zero in every set of digits, this affects the sum of the remainders. Normally the sum of the remainders is 0, but now, the presence of an extra zero causes one failure of our divisibility test.
To counteract this, I changed 2Xnot( to Xnot(. The 2 was originally there to make the test fail at 0, but now it passes at zero. Numbers that contain a zero in their digits, however, now have a min(ΔList(∟D of zero anyways (since there's 2 or more zeros in their lists) so this change does not cause any extra numbers to pass the test.

The benefit of this method is that, since there are now "two digits" produced from the number 1-9, the ΔList( function does not produce an error, allowing us to get rid of a special condition for single-digit numbers.

PhiNotPi

Posted 2015-09-29T14:51:44.130

Reputation: 26 739

3

Perl, 97 bytes

print+($n=$_,$/)x(!/0/&(y///c==grep{2>eval"$n=~y/$_//"}/./g)&&y///c==grep!($n%$_),/./g)for 1..1e7

Takes a while to run, but produces the required output, change to 1e3 for a quicker example!

Dom Hastings

Posted 2015-09-29T14:51:44.130

Reputation: 16 415

I'm not in a position to try this at the moment but, instead of y///c==grep{2>eval"$n=~y/$_//"}/./g, could you use something along the lines of !/(.).*\1/? – msh210 – 2018-05-11T09:04:11.417

@msh210 Almost certainly! I think that would be my default now, but changing this would only end up making it closer to steve's or Jarmex's answers, which are far superior! Thanks for taking a look though!

– Dom Hastings – 2018-05-11T09:23:26.757

3

Julia, 88 bytes

print(join(filter(i->(d=digits(i);0∉d&&d==unique(d)&&all(j->i%j<1,d)),1:9867312)," "))

This simply takes all numbers from 1 up to the largest Lynch-Bell number and filters them down to only the Lynch-Bell numbers.

Ungolfed:

lynch = filter(i -> (d = digits(i);
                     0 ∉ d &&
                     d == unique(d) &&
                     all(j -> i % j == 0, d)),
               1:9867312)

print(join(lynch, " "))

Alex A.

Posted 2015-09-29T14:51:44.130

Reputation: 23 761

3

Python 2, 101 bytes

print[i for i in range(6**9)if'0'not in`i`and len(set(`i`))==len(`i`)and all(i%int(k)==0for k in`i`)]

You can omit the print in the interpreter get to 96. Used 6**9 since it is 8 digits while the largest monday number is only 7 digits, something like 9**9 would probably take a long time, 6**9 only takes about 10 seconds.

Rohcana

Posted 2015-09-29T14:51:44.130

Reputation: 210

As pointed out on a couple of questions 1e7 is shorter than both – Holloway – 2015-10-02T08:58:37.460

@Trengot 1e7 is a float, range takes integers. – Rohcana – 2015-10-02T09:12:13.253

Very true. Hadn't thought of that – Holloway – 2015-10-02T09:14:22.640

3

MATLAB, 100

o=49;for n=2:1e7 a=num2str(n);if all([diff(sort(a)) a~=48 ~mod(n,a-48)]) o=[o ',' a];end;end;disp(o)

And in a more readable format:

o=49;  %1 is always in there, so add the ASCII value. This prevents there being a ',' prefixed.
for n=2:1e7 
    a=num2str(n);
    if (all([diff(sort(a)) a~=48 ~mod(n,a-48)]))
        o=[o ',' a];
    end
end
disp(o)

Basically this counts through every number between \$1\$ and \$1\times10^7\$ and checks if they are a Monday number. Each number is converted to a string so that the digits can be dealt with individually.

The checks are as follows:

  1. First check if there are any duplicates. By sorting the array, if the difference between any consecutive digits is zero, then there are duplicates

    diff(sort(a))
    
  2. Check if there are any zeros. The ASCII for 0 is 48, so we check that all digits are not equal to that.

    a~=48
    
  3. Check if it is divisible by all its digits. We check that the remainder when dividing by each digit (converted from ASCII to decimal, hence -48) is zero.

    ~mod(n,a-48)
    

Finally we make sure that all() the checks are true, and if so we append it to a comma separated output string.

MATLAB has no STDOUT, so instead I print the result string at the end using disp()


This code is SLOW! I am still running it to make sure that it correctly finds all the Monday numbers, but looks good so far.

Update:

Code finished running. It prints the following:

1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162,168,175,184,216,248,264,312,315,324,384,396,412,432,612,624,648,672,728,735,784,816,824,864,936,1236,1248,1296,1326,1362,1368,1395,1632,1692,1764,1824,1926,1935,1962,2136,2184,2196,2316,2364,2436,2916,3126,3162,3168,3195,3216,3264,3276,3492,3612,3624,3648,3816,3864,3915,3924,4128,4172,4236,4368,4392,4632,4872,4896,4932,4968,6132,6192,6312,6324,6384,6432,6912,6984,8136,8496,8736,9126,9135,9162,9216,9315,9324,9432,9612,9648,9864,12384,12648,12768,12864,13248,13824,13896,13968,14328,14728,14832,16248,16824,17248,18264,18432,18624,18936,19368,21384,21648,21784,21864,23184,24168,24816,26184,27384,28416,29736,31248,31824,31896,31968,32184,34128,36792,37128,37296,37926,38472,39168,39816,41328,41832,42168,42816,43128,43176,46128,46872,48216,48312,61248,61824,62184,64128,68712,72184,73164,73248,73416,73962,78624,79128,79632,81264,81432,81624,81936,82416,84216,84312,84672,87192,89136,89712,91368,91476,91728,92736,93168,93816,98136,123648,123864,123984,124368,126384,129384,132648,132864,132984,134928,136248,136824,138264,138624,139248,139824,142368,143928,146328,146832,148392,148632,149328,149832,162384,163248,163824,164328,164832,167328,167832,168432,172368,183264,183624,184392,184632,186432,189432,192384,193248,193824,194328,194832,198432,213648,213864,213984,214368,216384,218736,219384,231648,231864,231984,234168,234816,236184,238416,239184,241368,243168,243768,243816,247968,248136,248976,261384,263184,273168,281736,283416,284136,291384,293184,297864,312648,312864,312984,314928,316248,316824,318264,318624,319248,319824,321648,321864,321984,324168,324816,326184,328416,329184,341928,342168,342816,346128,348192,348216,348912,349128,361248,361824,361872,362184,364128,364728,367248,376824,381264,381624,382416,384192,384216,384912,391248,391824,392184,394128,412368,413928,416328,416832,418392,418632,419328,419832,421368,423168,423816,427896,428136,428736,431928,432168,432768,432816,436128,438192,438216,438912,439128,461328,461832,463128,468312,469728,478296,478632,481392,481632,482136,483192,483216,483672,483912,486312,489312,491328,491832,493128,498312,612384,613248,613824,613872,614328,614832,618432,621384,623184,623784,627984,631248,631824,632184,634128,634872,641328,641832,643128,648312,671328,671832,681432,684312,689472,732648,732816,742896,746928,762384,768432,783216,789264,796824,813264,813624,814392,814632,816432,819432,823416,824136,824376,831264,831624,832416,834192,834216,834912,836472,841392,841632,842136,843192,843216,843912,846312,849312,861432,864312,873264,891432,894312,897624,912384,913248,913824,914328,914832,918432,921384,923184,927864,931248,931824,932184,934128,941328,941832,943128,948312,976248,978264,981432,984312,1289736,1293768,1369872,1372896,1376928,1382976,1679328,1679832,1687392,1738296,1823976,1863792,1876392,1923768,1936872,1982736,2137968,2138976,2189376,2317896,2789136,2793168,2819376,2831976,2931768,2937816,2978136,2983176,3186792,3187296,3196872,3271968,3297168,3298176,3619728,3678192,3712968,3768912,3796128,3816792,3817296,3867192,3869712,3927168,3928176,6139728,6379128,6387192,6389712,6391728,6719328,6719832,6731928,6893712,6913872,6971328,6971832,7168392,7198632,7231896,7291368,7329168,7361928,7392168,7398216,7613928,7639128,7829136,7836192,7839216,7861392,7863912,7891632,7892136,7916328,7916832,7921368,8123976,8163792,8176392,8219736,8312976,8367912,8617392,8731296,8796312,8912736,8973216,9163728,9176328,9176832,9182376,9231768,9237816,9278136,9283176,9617328,9617832,9678312,9718632,9723168,9781632,9782136,9812376,9867312

Which if you run this code with that as the input:

nums = length(strsplit(stdout,','))

Yeilds 548.

Tom Carpenter

Posted 2015-09-29T14:51:44.130

Reputation: 3 990

3

Ruby, 79

?1.upto(?9*7){|s|a=s.chars;a.uniq!||a.any?{|x|x<?1||0<eval([s,x]*?%)}||puts(s)}

More interesting but slightly longer solution with a regex:

?1.upto(?9*7){|s|s[/(.).*\1|[0#{(1..9).map{|*x|x*eval([s,x]*?%)}*''}]/]||puts(s)}

In each case, we're using Ruby's ability to iterate over strings as though they were decimal integers: ?1.upto(?9*7) is equivalent to 1.upto(9999999).map(&:to_s).each. We join the string to each nonzero digit using the modulo operator, and eval the result, to check for divisibility.

Bonus Ruby 1.8 solution (requires -l flag for proper output):

'1'.upto('9'*7){|$_|~/(.).*\1|[0#{(1..9).map{|*x|x*eval("#$_%#{x}")}}]/||print}

1.8 allowed the block iterator to be a global variable. Assigning to $_ makes it the implicit receiver for string operations. We also get to interpolate arrays into the regular expression more easily: in 1.8, /[#{[1,2]}]/ evaluates to /[12]/.

histocrat

Posted 2015-09-29T14:51:44.130

Reputation: 20 600

Now that Ruby 2.4 has a digits function on integers, you can save bytes from the eval hack since you aren't operating on strings any more! 63 bytes. – Value Ink – 2019-05-08T02:45:16.913

3

Javascript (ES6), 106 90 83 bytes

Kids, don't try this at home; JS will not be happy with the prospect of looping through every digit of every integer from one to ten million with a regex.

for(i=0;i<1e7;i++)/(.).*\1|0/.test(i)||+`${i}`.replace(/./g,j=>i%j)||console.log(i)

The first regex (props to @Jarmex) returns true if the number contains duplicate digits or zeroes. If this turns out false, the program move on to the second, which replaces each digit j with i%j. The result is all zeroes if it's divisible by all of it's digits, in which case it moves on to console.log(i).

Suggestions welcome!

ETHproductions

Posted 2015-09-29T14:51:44.130

Reputation: 47 880

3

Ruby, 130 bytes

... not counting whitespace

New to programming,just wanted to participate

c=0
(0..10**7).each do |x| 
  a=x.to_s.split('')
  c+=1 if !a.include?('0')&& a.uniq!.eql?(nil)&&a.all?{|y| x.modulo(y.to_i).zero?} 
end
p c

skeezy_D

Posted 2015-09-29T14:51:44.130

Reputation: 31

2

Welcome to PPCG! Check out some additional Tips for Ruby to help get that code length down.

– AdmBorkBork – 2015-09-30T02:43:49.857

3

Pip, 25 bytes

Fa,t**7Ia#=UQa&0=$+a%^aPa

Outputs each number on its own line. This has been running for about 10 minutes and gotten up to 984312 so far, but I'm pretty sure it's correct. (Edit: Couple hours later... code finished, generated all 548 of 'em.)

Here's a Python-esque pseudocode rendition:

for a in range(10**7):
  if lengthEqual(a, set(a)) and 0 == sum(a%d for d in digits(a)):
    print(a)

The #= operator compares two iterables by length. If the number of UniQue characters in a is the same as the number of characters in a, there are no repeats.

The divisible-by-each-digit check is from one of my Pip example programs. I wrote it after seeing the earlier challenge, but didn't post it there because the language was newer than the question. Otherwise, at 8 bytes, it would be the winning answer to that question. Here's a step-by-step explanation:

      ^a   Split num into an array of its digits
    a%     Take num mod each of those digits; if a digit is zero, the result will be nil
  $+       Sum the resulting list (note: summing a list containing nil results in nil!)
0=         Iff the sum equals 0, return 1 (true); otherwise (>0 or nil), return 0 (false)

DLosc

Posted 2015-09-29T14:51:44.130

Reputation: 21 213

This is a pretty neat language! Nice to see something other than stack-based golfing. – AdmBorkBork – 2015-09-30T03:07:25.163

1@TimmyD If you want to see non-stack based golfing, there tends to be quite a bit of Pyth around. – Reto Koradi – 2015-10-01T05:06:43.733

@RetoKoradi But if you want to see non-stack-based golfing with infix operators, Pip is for you. ;^) – DLosc – 2015-10-01T19:06:24.380

Couple hours later It's a good thing performance isn't taken into account. – Holloway – 2015-10-02T09:01:11.520

3

JavaScript (ES6), 76

/* Answer below. For testing purpose, redirect consoloe.log */ console.log=x=>document.write(x+' ')

for(i=0;i++<1e7;)/0|(.).*\1/.test(i)||[...i+''].some(d=>i%d)||console.log(i)

The regexp test for 0 or repeated digits. Then the digits array is checked looking for a non-zero modulo for any digit.

here is the explanation of the 7 digit max.

edc65

Posted 2015-09-29T14:51:44.130

Reputation: 31 086

3

C, 122 bytes

i,j,m,a;void f(){for(i=1;i<1e8;++i){for(m=0,j=i;j;j/=10){a=j%10;if(!a||m&(1<<a)||i%a)goto n;m|=1<<a;}printf("%d ",i);n:;}}

Prettier:

i,j,m,a;
void f()
{
    for (i=1; i<1e8; ++i){
        for (m=0, j=i;  j;  j/=10) {
            a = j%10;
            if (!a || m&(1<<a) || i%a)
                goto n;
            m|=1<<a;
        }
        printf("%d ",i);
    n:;
    }
}

For each candidate i, we iterate its digits a in little-endian order, keeping track of seen digits in the bits of m. If the loop completes, then all digits are factors of i and we saw no zeros or repeated digits, so print it, otherwise we exit early to continue the outer loop.

Toby Speight

Posted 2015-09-29T14:51:44.130

Reputation: 5 058

Good to the the goto command being used. – Shaun Bebbers – 2019-05-07T14:39:03.020

2

Jelly, 11 bytes

9œ!ṖẎgḌ$ƑƇḌ

This uses the two-week old œ! atom. Actually fast enough to run on TIO.

Try it online!

How it works

9œ!ṖẎgḌ$ƑƇḌ  Main link. No arguments.

9            Set the return value to 9.
   R         Pop; yield [1, ..., 8].
 œ!          Promote 9 to [1, ..., 9] and generate all permutations of length k,
             each k in the right argument [1, ..., 8].
    Ẏ        Tighten; dump all digit lists in a single array.
         Ƈ   Comb; keep only digit lists for which the link to the left returns 1.
        Ƒ      Fixed; return 1 iff calling the link to the left returns its argument.
       $         Combine the two links to the left into a monadic chain.
      Ḍ            Undecimal; convert the digit list into an integer.
     g             Take the GCD of each digit and the integer.

Dennis

Posted 2015-09-29T14:51:44.130

Reputation: 196 637

2

Japt, 21 17 bytes

-4 thanks to Shaggy

1e7õ fÈ¥ì_â f myX

Try it online!

ASCII-only

Posted 2015-09-29T14:51:44.130

Reputation: 4 687

1e5o fÈ¥ì â ¬k_¥0ªX%Z is faster, but sadly returns 0 :( – ASCII-only – 2019-02-26T01:13:23.887

I think this works for 18.

– Shaggy – 2019-02-26T08:43:38.313

@Shaggy Huh, I swear !<whatever> never works when I try it. Also, huh... didn't realize those had no-op as the default function (basically) – ASCII-only – 2019-02-26T09:38:48.523

17 bytes – Shaggy – 2019-02-26T10:09:22.777

2

gawk, 99 bytes

BEGIN{for(;8>(l=split(++i,a,_));printf f?f=_:i RS)for(j in a)f=i~0||i%(d=a[j])||i-d*10^(l-j)~d?1:f}

I could reduce that to 97 if I would use END instead of BEGIN, but then you would have to press Ctrl-D to start the actual output, signalling that there will be no input.

I could reduce it to even 94 if I would write nothing instead of BEGIN or END, but then you would have to press the return key once to start it, which could be counted as input.

It simply goes over the digits of each number and tests if the criteria are met.

i~0               :  number contains a `0`?                          -> trash
i%(d=a[j])        :  number not divisible by current digit?          -> trash
i-d*10^(l-j)~d    :  I removed the current digit from the number yet it
                  :  still contains it?                              -> trash

Takes 140 seconds to terminate on my Core 2 Duo.

Cabbie407

Posted 2015-09-29T14:51:44.130

Reputation: 1 158

2

CJam, 34 bytes

1e7{_:TAb___&=\{T\T)e|%}%:+!**},N*

Lynn

Posted 2015-09-29T14:51:44.130

Reputation: 55 648

2

Lua, 129 bytes

I've eschewed the string approach for pure digit-crunching, which seems a bit speedier and probably saved me some bytes as well. (I'll have test that theory, but Lua string handling is pretty verbose compared to some other languages.)

for i=1,1e7 do t={[0]=1}j=i while j>0 do c=j%10 if t[c]or i%c>0 then break end t[c]=1 j=(j-c)/10 if j==0 then print(i)end end end

criptych stands with Monica

Posted 2015-09-29T14:51:44.130

Reputation: 181

1

Jelly, 13 bytes

%DẸ<DQƑ$µ548#

(Language is newer than the challenge.)

Try it online!

Explanation

%DẸ<DQƑ$       Helper function: is this a Monday number?
   <             Acts as a “not P and Q” gate here, between:
%D                 Take N modulo each of its digits.
  Ẹ                  Is any truthy? (NaN is truthy.)
                 And:
    DQƑ$           Are the digits are unique (0/1)?

        µ548#  Find the first 548 matches.

Lynn

Posted 2015-09-29T14:51:44.130

Reputation: 55 648

%D<ŒQẠµ100# should be equivalent. – Dennis – 2019-01-01T02:18:06.747

1

APL (Dyalog Unicode), 27 bytesSBCS

Full program.

⍸(∧/'0'∘∊<≡∘∪⍨>⍎¨|⍎)∘⍕¨⍳1E9

Try it online! (only up to 10⁵ due to run time — change 1E5 to 1E9 for full list)

⍳1E9integers from 1 to a 10⁹

()∘⍕¨ on the string representation of each:

 execute it (giving the original integer back)

⍎¨| division remainders of that when divided by the execution of each character of that

 …> mask for whether the following is greater than each of those:

  ≡∘∪⍨ is the character list identical to the unique characters in itself?

 …< mask for whether the following is less than each of those:

  '0'∘∊ is the character zero a member of the string representation?

∧/ are those all true? (lit. AND-reduction)

indices where true

Adám

Posted 2015-09-29T14:51:44.130

Reputation: 37 779

1

Common Lisp, 146 bytes

(dotimes(i 1e8)(and(equal(setq a(format()"~d"i))(remove-duplicates a))(not(find #\0 a))(every(lambda(x)(=(mod i(-(char-code x)48))0))a)(print i)))

Try it online! (where it stops at 3928176 after 60 seconds).

Renzo

Posted 2015-09-29T14:51:44.130

Reputation: 2 260

1

C, 111

h(){int i=0,k,z,m,j;for(;i++<1E7;){for(m=-1,k=i;(z=k%10)&&m&(j=1<<z)&&i%z==0;k/=10,m&=~j);k||printf("%u ",i);}}

ungolfed, and partial test:

h()
{int i=0,k,z,m,j;
 for(;i++<1E7;)
  {for(m=-1,k=i;(z=k%10)&&m&(j=1<<z)&&i%z==0;k/=10,m&=~j);
   k||printf("%u ",i);
  }
}

main(){h();printf("\n");}

1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192 
...
9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312

Easy in C...

RosLuP

Posted 2015-09-29T14:51:44.130

Reputation: 3 036

103 bytes – ceilingcat – 2019-01-02T17:53:51.113

@ceilingcat I use some your suggestions... It is ok or I came back with the previous saved post? I do not use variables without "int" because here it doesn't compile – RosLuP – 2019-01-03T10:34:44.230

1

PowerShell (reference implementation)

Whoops! Forgot to post this right when I asked the question! I meant to post this as an example / reference implementation, as it's pseudocode-y enough that people should be able to follow the logic. Doesn't seem to serve much purpose now, given the plethora of other answers, but I might as well still post it.

for($i=1; $I -le 9867312; $i++){
  $monday=$true
  $index=0
  $num=[char[]]$i.ToString()
  $digits=@()
  while($monday -and $index -lt $num.length){
    switch($num[$index]){
      '0'{$a=0}
      '1'{$a=1}
      '2'{$a=2}
      '3'{$a=3}
      '4'{$a=4}
      '5'{$a=5}
      '6'{$a=6}
      '7'{$a=7}
      '8'{$a=8}
      '9'{$a=9}
    }
    if([array]::IndexOf($digits,$a) -ge 0){ $monday=$false }
    if($a -eq 0){ $monday=$false }
    elseif(($i%$a) -gt 0){ $monday=$false }
    $index++
    $digits+=$a
  }
  if($monday){$i}
}

AdmBorkBork

Posted 2015-09-29T14:51:44.130

Reputation: 41 581

1

CJam, 23 bytes

1e7{_Ab___|=+:df%:+!},p

That's far too slow for the online interpreter, but you can it for a subset: Chrome | Firefox

Test run

$ cjam <(echo '1e7{_Ab___|=+:df%:+!},p') # Output
[1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192 6312 6324 6384 6432 6912 6984 8136 8496 8736 9126 9135 9162 9216 9315 9324 9432 9612 9648 9864 12384 12648 12768 12864 13248 13824 13896 13968 14328 14728 14832 16248 16824 17248 18264 18432 18624 18936 19368 21384 21648 21784 21864 23184 24168 24816 26184 27384 28416 29736 31248 31824 31896 31968 32184 34128 36792 37128 37296 37926 38472 39168 39816 41328 41832 42168 42816 43128 43176 46128 46872 48216 48312 61248 61824 62184 64128 68712 72184 73164 73248 73416 73962 78624 79128 79632 81264 81432 81624 81936 82416 84216 84312 84672 87192 89136 89712 91368 91476 91728 92736 93168 93816 98136 123648 123864 123984 124368 126384 129384 132648 132864 132984 134928 136248 136824 138264 138624 139248 139824 142368 143928 146328 146832 148392 148632 149328 149832 162384 163248 163824 164328 164832 167328 167832 168432 172368 183264 183624 184392 184632 186432 189432 192384 193248 193824 194328 194832 198432 213648 213864 213984 214368 216384 218736 219384 231648 231864 231984 234168 234816 236184 238416 239184 241368 243168 243768 243816 247968 248136 248976 261384 263184 273168 281736 283416 284136 291384 293184 297864 312648 312864 312984 314928 316248 316824 318264 318624 319248 319824 321648 321864 321984 324168 324816 326184 328416 329184 341928 342168 342816 346128 348192 348216 348912 349128 361248 361824 361872 362184 364128 364728 367248 376824 381264 381624 382416 384192 384216 384912 391248 391824 392184 394128 412368 413928 416328 416832 418392 418632 419328 419832 421368 423168 423816 427896 428136 428736 431928 432168 432768 432816 436128 438192 438216 438912 439128 461328 461832 463128 468312 469728 478296 478632 481392 481632 482136 483192 483216 483672 483912 486312 489312 491328 491832 493128 498312 612384 613248 613824 613872 614328 614832 618432 621384 623184 623784 627984 631248 631824 632184 634128 634872 641328 641832 643128 648312 671328 671832 681432 684312 689472 732648 732816 742896 746928 762384 768432 783216 789264 796824 813264 813624 814392 814632 816432 819432 823416 824136 824376 831264 831624 832416 834192 834216 834912 836472 841392 841632 842136 843192 843216 843912 846312 849312 861432 864312 873264 891432 894312 897624 912384 913248 913824 914328 914832 918432 921384 923184 927864 931248 931824 932184 934128 941328 941832 943128 948312 976248 978264 981432 984312 1289736 1293768 1369872 1372896 1376928 1382976 1679328 1679832 1687392 1738296 1823976 1863792 1876392 1923768 1936872 1982736 2137968 2138976 2189376 2317896 2789136 2793168 2819376 2831976 2931768 2937816 2978136 2983176 3186792 3187296 3196872 3271968 3297168 3298176 3619728 3678192 3712968 3768912 3796128 3816792 3817296 3867192 3869712 3927168 3928176 6139728 6379128 6387192 6389712 6391728 6719328 6719832 6731928 6893712 6913872 6971328 6971832 7168392 7198632 7231896 7291368 7329168 7361928 7392168 7398216 7613928 7639128 7829136 7836192 7839216 7861392 7863912 7891632 7892136 7916328 7916832 7921368 8123976 8163792 8176392 8219736 8312976 8367912 8617392 8731296 8796312 8912736 8973216 9163728 9176328 9176832 9182376 9231768 9237816 9278136 9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312]
$ cjam <(echo '1e7{_Ab___|=+:df%:+!},,') # Count
548

Dennis

Posted 2015-09-29T14:51:44.130

Reputation: 196 637

0

Retina, 77 bytes

Language postdates challenge

24+%`$
$`$"$`_
%(~`.+
^¶ $.&
\d
*_ 
)|'0L$` (?!(_+)\b.* \1+$)
$.'
A`0|(.).*\1

Try it online!

Note: The TIO link only checks up to 8191, but that is taking 40+ seconds already and the algorithm is at least quadratic in the biggest number it checks in both time and memory. The solution shown above would theoretically check up to 224-1, which includes all Lynch-Bell numbers

TwiNight

Posted 2015-09-29T14:51:44.130

Reputation: 4 187

0

Charcoal, 23 bytes

ΦEXχ⁷Iι∧Πι¬Φι∨⁻μ⌕ιλ﹪κIλ

Try it online! for numbers of up to five digits (too slow for larger numbers). Explanation:

   χ                    Predefined variable 10
  X                     Raised to power
    ⁷                   Literal 7
 E                      Map over implicit range
      ι                 Current value
     I                  Cast to string
Φ                       Filter over list of strings
         ι              Current string
        Π               Digital product (is nonzero)
       ∧                Logical And
          ¬             Logical Not
            ι           Current string
           Φ            Filter over digits as characters
               μ         Inner index
              ⁻          Minus
                ⌕        First position of
                  λ      Current character in
                 ι       Current string
             ∨          Logical Or
                    κ   Outer index
                   ﹪    Modulo
                      λ Current character
                     I  Cast to integer

Neil

Posted 2015-09-29T14:51:44.130

Reputation: 95 035

0

C# (Visual C# Interactive Compiler), 103 bytes

for(int i=0;++i<1e7;)if((i+"").GroupBy(c=>c).All(g=>g.Count()<2&g.Key>48&&i%(g.Key-48)<1))Write(i+" ");

Try it online!

To be fair, this started off as RobIII's answer, but it has improved quite a bit.

-5 bytes thanks to @EmbodimentOfIgnorance!

This answer also uses the C# REPL which wasn't quite released at the time that this question was asked.

Less golfed code...

// iterate all possible numbers
for(int i=0;++i<1e7;)
  // convert number to string
  if((i+"")
    // group by digits
    .GroupBy(c=>c)
    // ensure each digit only occurs
    // once, the current number is
    // divisible by each digit, and that
    // there are no zeros
    .All(g=>g.Count()<2&
      g.Key>48&&
      i%(g.Key-48)<1
    )
  )
    // print current number if tests pass
    Write(i+" ");

dana

Posted 2015-09-29T14:51:44.130

Reputation: 2 541

1This and this are both 110 bytes. – Embodiment of Ignorance – 2019-01-01T22:07:13.103

0

PHP, 140 bytes

for(;;$p=1,$n++)if(!in_array(0,$a=str_split($n))&&count($a)==count(array_unique($a))){foreach($a as$b)if($n%$b!=0)$p=0;echo$p==1?"$n ":'';}

Usage

php -r file.php

Output terminal

1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192 6312 6324 6384 6432 6912 6984 8136 8496 8736 9126 9135 9162 9216 9315 9324 9432 9612 9648 9864 12384 12648 12768 12864 13248 13824 13896 13968 14328 14728 14832 16248 16824 17248 18264 18432 18624 18936 19368 21384 21648 21784 21864 23184 24168 24816 26184 27384 28416 29736 31248 31824 31896 31968 32184 34128 36792 37128 37296 37926 38472 39168 39816 41328 41832 42168 42816 43128 43176 46128 46872 48216 48312 61248 61824 62184 64128 68712 72184 73164 73248 73416 73962 78624 79128 79632 81264 81432 81624 81936 82416 84216 84312 84672 87192 89136 89712 91368 91476 91728 92736 93168 93816 98136 123648 123864 123984 124368 126384 129384 132648 132864 132984 134928 136248 136824 138264 138624 139248 139824 142368 143928 146328 146832 148392 148632 149328 149832 162384 163248 163824 164328 164832 167328 167832 168432 172368 183264 183624 184392 184632 186432 189432 192384 193248 193824 194328 194832 198432 213648 213864 213984 214368 216384 218736 219384 231648 231864 231984 234168 234816 236184 238416 239184 241368 243168 243768 243816 247968 248136 248976 261384 263184 273168 281736 283416 284136 291384 293184 297864 312648 312864 312984 314928 316248 316824 318264 318624 319248 319824 321648 321864 321984 324168 324816 326184 328416 329184 341928 342168 342816 346128 348192 348216 348912 349128 361248 361824 361872 362184 364128 364728 367248 376824 381264 381624 382416 384192 384216 384912 391248 391824 392184 394128 412368 413928 416328 416832 418392 418632 419328 419832 421368 423168 423816 427896 428136 428736 431928 432168 432768 432816 436128 438192 438216 438912 439128 461328 461832 463128 468312 469728 478296 478632 481392 481632 482136 483192 483216 483672 483912 486312 489312 491328 491832 493128 498312 612384 613248 613824 613872 614328 614832 618432 621384 623184 623784 627984 631248 631824 632184 634128 634872 641328 641832 643128 648312 671328 671832 681432 684312 689472 732648 732816 742896 746928 762384 768432 783216 789264 796824 813264 813624 814392 814632 816432 819432 823416 824136 824376 831264 831624 832416 834192 834216 834912 836472 841392 841632 842136 843192 843216 843912 846312 849312 861432 864312 873264 891432 894312 897624 912384 913248 913824 914328 914832 918432 921384 923184 927864 931248 931824 932184 934128 941328 941832 943128 948312 976248 978264 981432 984312 1289736 1293768 1369872 1372896 1376928 1382976 1679328 1679832 1687392 1738296 1823976 1863792 1876392 1923768 1936872 1982736 2137968 2138976 2189376 2317896 2789136 2793168 2819376 2831976 2931768 2937816 2978136 2983176 3186792 3187296 3196872 3271968 3297168 3298176 3619728 3678192 3712968 3768912 3796128 3816792 3817296 3867192 3869712 3927168 3928176 6139728 6379128 6387192 6389712 6391728 6719328 6719832 6731928 6893712 6913872 6971328 6971832 7168392 7198632 7231896 7291368 7329168 7361928 7392168 7398216 7613928 7639128 7829136 7836192 7839216 7861392 7863912 7891632 7892136 7916328 7916832 7921368 8123976 8163792 8176392 8219736 8312976 8367912 8617392 8731296 8796312 8912736 8973216 9163728 9176328 9176832 9182376 9231768 9237816 9278136 9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312

Test Online

Mario

Posted 2015-09-29T14:51:44.130

Reputation: 3 043

0

APL(NARS), 43 chars, 86 bytes

{x/⍨{{0∊⍵:0⋄⍵≢∪⍵:0⋄∧/0=⍵∣w}⍎¨⍕w←⍵}¨x←⍳⍵}1E7

here in 45 seconds arrive to 1E5 (not 1E7 as example would pretend) This below would be the translation of one C solution in APL... in 50 seconds it arrive to 3E5

r←h;i;j;k;z;m
i←0⋄r←⍬
→0×⍳3E7<i+←1⋄m←9⍴1⋄k←i
→4×⍳0=z←10∣k⋄→2×⍳0=z⊃m⋄→2×⍳0≠z∣i⋄k←⌊k÷10⋄m[z]←0⋄→3
→2×⍳k≠0⋄r←r,i⋄→2

in 50 seconds 1..297864 it seems 3 time faster of first function, it would arrive to 1E7 in 28 minutes here.

If it is written the function for doing combination:

c←{0≥k←⍺-1:,¨⍵⋄k≥i←≢w←⍵:,¯1⋄↑,/{w[⍵],¨k c w[(⍳i)∼⍳⍵]}¨⍳i-k}

and the function for doing permutation:

q←{1≥k←≢w←,⍵:⊂,⍵⋄a←⍳k⋄↑,/{w[⍵],¨q w[a∼⍵]}¨a}

for build the code for doing the result:

↑,/{10⊥¨↑,/(0≠≢¨v)/v←{b/⍨z←{∧/0=⍵∣10⊥⍵}¨b←q⍵}¨⍵ c⍳9}¨⍳7   

but it runs only in 1 minute and 33 seconds for 1..1E7 it seems the algorithm is faster than the one used above functions (but it not goes below 1 minute, at last here)

RosLuP

Posted 2015-09-29T14:51:44.130

Reputation: 3 036

0

Perl 6, 42 bytes

put grep {!/(.).*$0/&&$_%%+.comb.all},^1e7

Try it online!

A full program that creates a bunch of warnings, but eventually goes through. Times out on TIO, but you can test it by changing the final range, for example 1000.

Explanation:

    grep {                          },^1e7    # Filter from the range 0 to 10000000
          !/(.).*$0/       # The number does not contain duplicate digits
                    &&     # And
                      $_%%             # The number is divisible by
                                 .all  # all of
                           +.comb      # The digits of the number
                                       # Note that $_%%0 is False
put  # And print the list

Jo King

Posted 2015-09-29T14:51:44.130

Reputation: 38 234

0

C# (Visual C# Interactive Compiler), 85 bytes

for(int i=1;i<1e7;i++)if((i+"").All(c=>i%(c-48d)<1&(i+"").Count(x=>x==c)<2))Print(i);

Try it online!

Embodiment of Ignorance

Posted 2015-09-29T14:51:44.130

Reputation: 7 014

0

K 44 Bytes

&{(&/x=b*_x%b)&(b~?b)&x&~0 in b:10\:x}'!_1e7
  • _1e7 generates 0..9999999

  • &{..}'!_1e7 applies lambda to each 0.9999999 and prints indexes where lambda is true

  • Lambda has four expressions (..)&(..)&..&.. and return true if each .. is true (& is and)

  • b:10\:x set b to decimal digits of argument x

  • ~0 in b reads "not 0 in b"

  • x&~0 in b true if x is not 0 and not 0-digit in b. x& is necessary because 10:0 generates empty digits list instead of list with digit 0

  • b~?b reads as "b match unique b", and its true iff non-repeated digits in b

  • _x%b reads as "floor of x dividedBy each item of b"

  • &/x=b*_x%b reads "all x = digits * quotient of integer divission"

J. Sendra

Posted 2015-09-29T14:51:44.130

Reputation: 396

0

Coffeescript, 83 bytes

No merit for this answer (and therefore no upvote please), this is a translation to coffeescript of @ETHproductions solution

/(.).*\1|0/.test(i)||+(""+i).replace(/./g,(j)=>i%j)||console.log i for i in[0..1e7]

Thanks for your implementation, it helped me to understand some tricks under the hood that can be useful. Wanted to comment your solution but not enough reputation to do that.

Hereafter is also the ES5 solution (101 bytes), running on node.js

for(i=1;i<=1e7;i++)/(.).*\1|0/.test(i)||+(""+i).replace(/./g,function(j){return i%j})||console.log(i)

dunpeal69

Posted 2015-09-29T14:51:44.130

Reputation: 51