Skip to content

Added Euler's totient Function #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update EulersFunction.java
  • Loading branch information
yanglbme authored Feb 4, 2019
commit 12215a11d3b77c45e074daf096fd1cf43a15cb93
7 changes: 4 additions & 3 deletions Others/EulersFunction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//You can read more about Euler's totient function https://en.wikipedia.org/wiki/Euler%27s_totient_function
// You can read more about Euler's totient function
// https://en.wikipedia.org/wiki/Euler%27s_totient_function
public class EulersFunction {
//This method returns us number of x that (x < n) and gcd(x, n) == 1 in O(sqrt(n)) time complexity;
// This method returns us number of x that (x < n) and gcd(x, n) == 1 in O(sqrt(n)) time complexity;
public static int getEuler(int n) {
int result = n;
for (int i = 2; i * i <= n; i++) {
Expand All @@ -13,7 +14,7 @@ public static int getEuler(int n) {
return result;
}
public static void main(String[] args) {
for(int i = 1; i < 100; i++) {
for (int i = 1; i < 100; i++) {
System.out.println(getEuler(i));
}
}
Expand Down