diff --git a/Fibonacci Series/fibonacci.py b/Fibonacci Series/fibonacci.py new file mode 100644 index 0000000..550db18 --- /dev/null +++ b/Fibonacci Series/fibonacci.py @@ -0,0 +1,26 @@ +# Function to return the Nth number of the modified Fibonacci series where A and B are the first two terms +def findNthNumber(a, b, n): + + # To store the current element which is the sum of previous two elements of the series + sum = 0 + + # This loop will terminate when the Nth element is found + for i in range(2, n): + sum = a + b + a = b + b = sum + + # Return the Nth element + return sum + +# Driver code +if __name__ == '__main__': + a = 5 + b = 7 + n = 10 + + print(findNthNumber(a, b, n)) + + + #the output is 343 +# you can test it by using any number of your choice \ No newline at end of file diff --git a/Sorting Number/Sorting_number.java b/Sorting Number/Sorting_number.java new file mode 100644 index 0000000..b61cae7 --- /dev/null +++ b/Sorting Number/Sorting_number.java @@ -0,0 +1,16 @@ + +// Arrays.sort(). +// It by default sorts in ascending order. +import java.util.Arrays; + +public class SortingNumber { + public static void main(String[] args) + { + int[] arr = { 13, 7, 6, 45, 21, 9, 101, 102 }; + + Arrays.sort(arr); + + System.out.printf("Sorted arr[] : %s", + Arrays.toString(arr)); + } +} \ No newline at end of file