summaryrefslogtreecommitdiffstats
path: root/056.bc
blob: e0b0f08e93ade8b172227fac001f2cc24c114f85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/bc

define digit_sum (n) {
    scale = 0
    sum = 0
    while (n > 0) {
        sum += (n % 10)
        n = n / 10
    }
    scale = 20
    return sum
}

max = 0
for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
        s = digit_sum(i^j)
        if (s > max) {
            max = s
        }
    }
}
max
halt