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

add FreeBASIC
(Realize in F#)
(add FreeBASIC)
Line 367:
= 936
= 999</pre>
 
=={{header|FreeBASIC}}==
This function does a bit more than the task asks for, just to make things interesting.
<lang freebasic>function divdignp( n as const integer ) as ubyte
'returns 1 if the number is divisible by its digits
' 2 if it is NOT divisible by the product of its digits
' 3 if both are true
' 0 if neither are true
dim as integer m = n, p = 1, r = 1, d
while m>0
d = m mod 10
m \= 10
p *= d
if d<>0 andalso n mod d <> 0 then r = 0
wend
if p<>0 andalso n mod p <> 0 then r += 2
return r
end function
 
for i as uinteger = 1 to 999
if divdignp(i) = 3 then print i;" ";
next i : print</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|Haskell}}==
781

edits