1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math math.ranges math.parser sequences kernel io locals ;
6 ! http://crazybob.org/BeustSequence.java.html
8 :: (count-numbers) ( remaining first value used max listener: ( -- ) -- ? )
10 [let* | digit [ i first + ]
12 value' [ i value + ] |
13 used mask bitand zero? [
29 ] any? ; inline recursive
31 :: count-numbers ( max listener -- )
32 10 iota [ 1 + 1 1 0 max listener (count-numbers) ] any? drop ;
37 5000000000 [ i 1 + i! ] count-numbers
38 i number>string " unique numbers." append print