#C196. Largest Prime Factor

    ID: 45222 Type: Default 1000ms 256MiB

Largest Prime Factor

Largest Prime Factor

Given a positive integer \( n \), your task is to compute its largest prime factor. A prime factor is a prime number that divides \( n \) exactly, without leaving a remainder. For example, if \( n = 13195 \), the prime factors are 5, 7, 13, and 29, and the largest of these is 29. The problem can be approached by dividing \( n \) repeatedly by its smallest prime factors until what remains is a prime number. Use the factorization formula: \( n = p_1^{\alpha_1} \times p_2^{\alpha_2} \times \cdots \), where \( p_i \) are prime factors.

inputFormat

A single positive integer ( n ) is provided via standard input.

outputFormat

Print the largest prime factor of ( n ) to standard output.## sample

13195
29

</p>