Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6454 |

@blackshadows | 6380 |

@mb1973 | 5714 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3709 |

@mantu_singh | 3556 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1285 |

@gurshehzadsingh | 1052 |

@pritsahkar2000 | 812 |

@satyamchhatrala | 804 |

@nithinreddy3210 | 801 |

@iib2019024 | 745 |

@mohanreddy8847 | 704 |

@iamchaitanyahegde | 662 |

@shafeeq3543 | 651 |

@workit | 646 |

@AkashLahoty | 642 |

Complete Leaderboard |

Consider Ø(n) as the Euler Totient Function for n. You will be given a positive integer **N** and you have to find the smallest positive integer** n**, n <= N for which the ratio n/Ø(n) is maximized.

**Example 1:**

Input:N =6Output:6Explanation:For n = 1, 2, 3, 4, 5 and 6 the values of the ratio are 1, 2, 1.5, 2, 1.25 and 3 respectively. The maximum is obtained at 6.

**Example 2:**

Input:N =50Output:30Explanation:For n = 1 to 50, the maximum value of the ratio is 3.75 which is obtained at n = 30.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **maximizeEulerRatio()** which takes an Integer N as input and returns the smallest positive integer (<= N) which maximizes the ratio n/Ø(n) is maximized.

**Expected Time Complexity:** O(constant)

**Expected Auxiliary Space:** O(constant)

**Constraints:**

1 <= N <= 10^{12}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Euler Totient

...