aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/laurent-rosenfeld/bc/ch-2.bc
blob: f813c4560d4c3ebe17da87d728f74e368196e9c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
fact[0] = 1
for (n = 1; n <= 9; n++) {
    fact[n] = n * fact[n - 1]
}
for (n = 1; n <= 50000; n++) {
    sum = 0
    i = n
    while (i > 0) {
        sum += fact[i % 10]
        i /= 10
    }
    if (sum == n) {
        print n, " "
    }
}
halt