Euler's Totient function for all numbers smaller than or equal to n in java

Following is a program to get the result of Euler’s Totient function for all numbers smaller than or equal to n when n is given.

Program

import java.util.Scanner;

public class EulerTotient {
   public static int gcd(int a,int b){
      int i, hcf = 0;
         for(i = 1; i 

Output

Enter the n value
10
1
1
1
2
2
2
2
3
3
4
Updated on: 2020-06-25T12:51:01+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements