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

Added Go
(Added Algol 68)
(Added Go)
Line 624:
{{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|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
<lang go>package main
 
import (
"fmt"
"rcu"
)
 
func main() {
var res []int
for n := 1; n < 1000; n++ {
digits := rcu.Digits(n, 10)
var all = true
for _, d := range digits {
if d == 0 || n%d != 0 {
all = false
break
}
}
if all {
prod := 1
for _, d := range digits {
prod *= d
}
if prod > 0 && n%prod != 0 {
res = append(res, n)
}
}
}
fmt.Println("Numbers < 1000 divisible by their digits, but not by the product thereof:")
for i, n := range res {
fmt.Printf("%4d", n)
if (i+1)%9 == 0 {
fmt.Println()
}
}
fmt.Printf("\n%d such numbers found\n", len(res))
}</lang>
 
{{out}}
<pre>
Numbers < 1000 divisible by their digits, but not by the product thereof:
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
 
45 such numbers found
</pre>
 
9,485

edits