We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2c20f3e + 9c81ec7 commit 94acf5fCopy full SHA for 94acf5f
Gcd.java
@@ -0,0 +1,17 @@
1
+class Test {
2
+
3
+ static int gcd(int a, int b)
4
+ {
5
+ if (b == 0)
6
+ return a;
7
+ return gcd(b, a % b);
8
+ }
9
10
+ // Driver method
11
+ public static void main(String[] args)
12
13
+ Scanner sc=new Scanner(System.in);
14
+ int a=sc.nextInt(),b=sc.nextInt();
15
+ System.out.println("GCD of " + a +" and " + b + " is " + gcd(a, b));
16
17
+}
Sorting Algorithm/Sort Nearly sorted array
@@ -0,0 +1,15 @@
+static void insertionSort(int A[], int size)
+{
+int i=0, k=0, j=0;
+for (i = 1; i < size; i++)
+ k = A[i];
+ j = i-1;
+ while (j >= 0 && A[j] > k)
+ A[j+1] = A[j];
+ j = j-1;
+ A[j+1] = k;
0 commit comments