Numbers divisible by their individual digits, but not by the product of their digits.: Difference between revisions

Added Forth solution
(add FreeBASIC)
(Added Forth solution)
Line 367:
= 936
= 999</pre>
 
=={{header|Forth}}==
{{works with|Gforth}}
<lang forth>: divisible? { n -- ? }
1 { p }
n
begin
dup 0 >
while
10 /mod swap
dup 0= if
2drop false exit
then
dup n swap mod 0<> if
2drop false exit
then
p * to p
repeat
drop n p mod 0<> ;
 
: main
0 { count }
1000 1 do
i divisible? if
i 4 .r
count 1+ to count
count 10 mod 0= if cr else space then
then
loop cr ;
 
main
bye</lang>
 
{{out}}
<pre>
22 33 44 48 55 66 77 88 99 122
124 126 155 162 168 184 222 244 248 264
288 324 333 336 366 396 412 424 444 448
488 515 555 636 648 666 728 777 784 824
848 864 888 936 999
</pre>
 
=={{header|FreeBASIC}}==
1,777

edits