Sum of the digits of n is substring of n: Difference between revisions

Added Go
m (Moved Python entry into correct alphabetical order.)
(Added Go)
Line 46:
{{out}}<pre>0 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 109 119 129 139 149 159 169 179 189 199 200 300 400 500 600 700 800 900 910 911 912 913 914 915 916 917 918 919</pre>
 
 
=={{header|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
<lang go>package main
 
import (
"fmt"
"rcu"
"strings"
)
 
func main() {
var numbers []int
for n := 0; n < 1000; n++ {
ns := fmt.Sprintf("%d", n)
ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
if strings.Contains(ns, ds) {
numbers = append(numbers, n)
}
}
fmt.Println("Numbers under 1,000 whose sum of digits is a substring of themselves:")
rcu.PrintTable(numbers, 8, 3, false)
fmt.Println()
fmt.Println(len(numbers), "such numbers found.")
}</lang>
 
{{out}}
<pre>
Numbers under 1,000 whose sum of digits is a substring of themselves:
0 1 2 3 4 5 6 7
8 9 10 20 30 40 50 60
70 80 90 100 109 119 129 139
149 159 169 179 189 199 200 300
400 500 600 700 800 900 910 911
912 913 914 915 916 917 918 919
 
48 such numbers found.
</pre>
 
=={{header|Julia}}==
9,490

edits