Maximum Square-Free Divisor
Updated
Problem statement
Your friend gives you a positive integer n. Find the largest positive divisor d of n that is not divisible by any perfect square greater than 1.
Equivalently, d must not be divisible by k^2 for any integer k >= 2. Such a number is called square-free. Return the maximum possible d.
Function
solve(n: long) → longExamples
Example 1
n = 4return = 2The divisors of 4 are 1, 2, and 4. The divisor 4 is divisible by the perfect square 4, while 2 is square-free. Return 2.
Example 2
n = 1return = 1The only positive divisor is 1. No perfect square greater than 1 divides it, so return 1.
Example 3
n = 72return = 672 = 2^3 * 3^2. A square-free divisor can use at most one factor of 2 and one factor of 3. Taking both gives the largest valid divisor, 6.
Constraints
1 <= n <= 10^12.- The input and return value use signed 64-bit integers.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
- Alien DictionaryOA · Seen Sep 2026
Similar questions at other companies
- Summarize Taxi Drivers and RidesBoston Consulting Group · OABoston Consulting Group interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count Valid Square PairsAuxoAI · OA
- Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA