-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.java
More file actions
101 lines (87 loc) · 1.73 KB
/
Copy pathFunctions.java
File metadata and controls
101 lines (87 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import java.util.Scanner;
public class Functions {
//circumference
// public static Double calculate_circum(Double rad)
// {
// return 2*3.14*rad;
// }
//count positive,negative,zeroes
// public static void countnos(int input)
// {
// int pos=0,neg=0,zer=0;
// while(input==1)
// {
// Scanner sc=new Scanner(System.in);
// System.out.println("enter the number");
// int n=sc.nextInt();
// if(n>0)
// pos++;
// else if(n<0)
// neg++;
// else
// zer++;
// System.out.println("want to continue yes(1) or no(0)");
// input=sc.nextInt();
// }
// System.out.println("positive are: "+pos+" negative are: "+neg+" zeroes are: "+zer);
// }
// public static void powerofx(int x,int n)
// {
// int res=1;
// for(int i=1;i<=n;i++)
// {
// res=res*x;
// }
// System.out.println("result: "+res);
// }
// public static void printfibo(int n)
// {
// int a=0,b=1;
// System.out.print(a+" ");
// if(n>1)
// {
// for(int i=2;i<=n;i++)
// {
// System.out.print(b+ " ");
// int next=a+b;
// a=b;
// b=next;
//
// }
// System.out.println();
// }
//
// }
public static void gcd(int a,int b) {
while(a!=b)
{
if(a>b)
//a is greater than b
a=a-b;
else
b=b-a;
}
System.out.println("gcd is: "+b);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
// System.out.println("hello");
Scanner sc=new Scanner(System.in);
// Double r=sc.nextDouble();
// System.out.println(calculate_circum(r));
//infinite loop using do while
// do
// {
//
// }while(true);
// int i=sc.nextInt();
// countnos(i);
int a=sc.nextInt();
int b=sc.nextInt();
gcd(a, b);
//
// powerofx(a, b);
// int n=sc.nextInt();
// printfibo(n);
}
}