From e3836e94e4ffd1673b0b726e7e90666bab466ba8 Mon Sep 17 00:00:00 2001 From: VicRen Date: Sat, 14 Nov 2020 10:21:58 +0800 Subject: [PATCH] 43: sub-string divisibility --- 43_substring_divisibility/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 43_substring_divisibility/main.go diff --git a/43_substring_divisibility/main.go b/43_substring_divisibility/main.go new file mode 100644 index 0000000..a7e8a78 --- /dev/null +++ b/43_substring_divisibility/main.go @@ -0,0 +1,17 @@ +package main + +import "fmt" + +func main() { + // d234 is divisible by 2 -> d4%2 == 0 + // d345 is divisible by 3 -> (d3+d4+d5)%3 == 0 + // d456 is divisible by 5 -> d6 == 5 || d6 == 0 + // d567 is divisible by 7 + // d678 is divisible by 11 -> d6 == 5 (if d6 == 0, d8 == d9) -> d678 = []int{506,517,528,539,561,572,583,594} + // d789 is divisible by 13 -> d6789 = []int{5286,5390,5728,5832} + // d8910 is divisible by 17 -> d678910 = []int{52867,53901,57289} + // d5678910 = []int{952867,357289} + // d345678910 = []int{30952867, 60357289,06357289} + // left digits = []int{1,4} + fmt.Println("sum:", 1430952867+1460357289+1406357289+4130952867+4160357289+4106357289) +}