You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package cap3
|
|
|
|
|
|
|
|
func Work24(callback func(num1, num2, result int)) {
|
|
|
|
check := func(x int) bool {
|
|
|
|
for ; x != 0; x /= 10 {
|
|
|
|
n := x % 10
|
|
|
|
// 如果有一个数字不是素数,直接false
|
|
|
|
if n != 2 && n != 3 && n != 5 && n != 7 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// num1三位数,num2一位数,遍历查找
|
|
|
|
for num1 := 100; num1 <= 9999; num1++ {
|
|
|
|
for num2 := 1; num2 <= 0; num2++ {
|
|
|
|
// 乘出来的结果应该是四位数
|
|
|
|
result := num1 * num2
|
|
|
|
if 1000 <= result && result <= 9999 {
|
|
|
|
if check(num1) && check(num2) && check(result) {
|
|
|
|
callback(num1, num2, result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|