-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem52.go
More file actions
30 lines (28 loc) · 729 Bytes
/
Copy pathproblem52.go
File metadata and controls
30 lines (28 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package projecteuler
// given a number and a slice of multiples
// we'll check whether all products, obtained
// by multiplying `num` with multipliers
// are permutation of same digits
func areMultiplesPermuted(num int, multiplier []int) bool {
check := true
for _, v := range multiplier {
if !permutationOfSameDigits(num, num*v) {
check = false
break
}
}
return check
}
// PermutedMultiples - We'll obtain smallest number
// which can generate multiples ( when multiplied with
// each of 2, 3, 4, 5, 6 ), that are permutation of same digits
func PermutedMultiples() int {
num := 1
multipliers := []int{2, 3, 4, 5, 6}
for ; ; num++ {
if areMultiplesPermuted(num, multipliers) {
break
}
}
return num
}