Most frequent factor

Write a procedure

    void factor(int n, int& f, int& q);

to store in @f@ the most frequent factor of @n@, and store in @q@ how many times it appears. If there is a tie, choose the smallest factor. For instance, if called with @n@ =450=213252= 450 = 2^1 \cdot 3^2 \cdot 5^2, the values after the call must be @f@ =3=3 and @q@ =2= 2.

Precondition

@n@ 2\ge 2

Observation

You only need to submit the required procedure; your main program will be ignored.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T10:11:31.713Z

© Jutge.org, 2006–2026.
https://jutge.org