Jump to content

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

(Added Algol W)
Line 768:
912 913 914 915 916 917 918 919
</pre>
 
=={{header|Kotlin}}==
{{trans|Go}}
<lang scala>fun digitSum(n: Int): Int {
var nn = n
var sum = 0
while (nn > 0) {
sum += (nn % 10)
nn /= 10
}
return sum
}
 
fun main() {
var c = 0
for (i in 0 until 1000) {
val ds = digitSum(i)
if (i.toString().contains(ds.toString())) {
print("%3d ".format(i))
 
c += 1
if (c == 8) {
println()
c = 0
}
}
}
println()
}</lang>
{{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|MAD}}==
1,452

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.