3765. Complete Prime Number Medium
1/**
2 * [3765] Complete Prime Number
3 *
4 * You are given an integer num.
5 * A number num is called a Complete <span data-keyword="prime-number">Prime Number</span> if every prefix and every suffix of num is prime.
6 * Return true if num is a Complete Prime Number, otherwise return false.
7 * Note:
8 *
9 * A prefix of a number is formed by the first k digits of the number.
10 * A suffix of a number is formed by the last k digits of the number.
11 * Single-digit numbers are considered Complete Prime Numbers only if they are prime.
12 *
13 *
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">num = 23</span>
17 * Output: <span class="example-io">true</span>
18 * Explanation:
19 *
20 * Prefixes of num = 23 are 2 and 23, both are prime.
21 * Suffixes of num = 23 are 3 and 23, both are prime.
22 * All prefixes and suffixes are prime, so 23 is a Complete Prime Number and the answer is true.
23 * </div>
24 * <strong class="example">Example 2:
25 * <div class="example-block">
26 * Input: <span class="example-io">num = 39</span>
27 * Output: <span class="example-io">false</span>
28 * Explanation:
29 *
30 * Prefixes of num = 39 are 3 and 39. 3 is prime, but 39 is not prime.
31 * Suffixes of num = 39 are 9 and 39. Both 9 and 39 are not prime.
32 * At least one prefix or suffix is not prime, so 39 is not a Complete Prime Number and the answer is false.
33 * </div>
34 * <strong class="example">Example 3:
35 * <div class="example-block">
36 * Input: <span class="example-io">num = 7</span>
37 * Output: <span class="example-io">true</span>
38 * Explanation:
39 *
40 * 7 is prime, so all its prefixes and suffixes are prime and the answer is true.
41 * </div>
42 *
43 * Constraints:
44 *
45 * 1 <= num <= 10^9
46 *
47 */
48pub struct Solution {}
49
50// problem: https://leetcode.com/problems/complete-prime-number/
51// discuss: https://leetcode.com/problems/complete-prime-number/discuss/?currentPage=1&orderBy=most_votes&query=
52
53// submission codes start here
54
55impl Solution {
56 pub fn complete_prime(num: i32) -> bool {
57 false
58 }
59}
60
61// submission codes end
62
63#[cfg(test)]
64mod tests {
65 use super::*;
66
67 #[test]
68 fn test_3765() {
69 }
70}
71Back
© 2026 bowen.ge All Rights Reserved.