File size: 1,280 Bytes
2069a76
 
0c28765
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8df63e2
 
2069a76
8df63e2
 
 
2069a76
8df63e2
 
 
 
 
 
ee48cc4
8df63e2
 
 
 
4567da9
 
2069a76
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gradio as gr

def prime_factors(n):
    """
    Compute the prime factorization of a positive integer.
    Args:
        n (int): The integer to factorize. Must be greater than 1.
    Returns:
        List[int]: A list of prime factors in ascending order.
    Raises:
        ValueError: If n is not greater than 1.
    """
    n = int(n)
    if n <= 1:
        raise ValueError("Input must be an integer greater than 1.")

    factors = []
    while n % 2 == 0:
        factors.append(2)
        n //= 2

    divisor = 3
    while divisor * divisor <= n:
        while n % divisor == 0:
            factors.append(divisor)
            n //= divisor
        divisor += 2

    if n > 1:
        factors.append(n)

    return factors


# def letter_counter(word, letter):
#     """Count the occurrences of a specific letter in a word.
    
#     Args:
#         word: The word or phrase to analyze
#         letter: The letter to count occurrences of
        
#     Returns:
#         The number of times the letter appears in the word
#     """
#     return word.lower().count(letter.lower()) + 100

demo = gr.Interface(
    fn=prime_factors,
    inputs=["text"],
    outputs="text",
    title="Prime Factors",
    description="Prime Factors"
)

demo.launch(mcp_server=True)