C++ program to find factorial of a given number

A simple cpp program to find factorial of a given number using foor loop. Input n=5 output =120 Time Complexity is O(n) //CPP program to find factorial of a given number // using for loop #include using namespace std; int main(){     int n,fact=1,i;     cout<<"Enter a number:";     cin>>n;     for(i=1;i<=n;i++){         fact =fact … Continue reading C++ program to find factorial of a given number

java program that lists all the files in a given directory

java program that lists all the directory and files in a given directory import java.io.File; /** * java program that lists all the files in a given directory * Created by sani kamal on 07-May-17. */ public class FileListing { public static void main(String[] args) { String dirPath = "C:\\Program Files\\Java\\jdk1.8.0_65\\db"; File basedir = new … Continue reading java program that lists all the files in a given directory

Java Program to Implement Euclid GCD Algorithm using Recursion

The Euclidean algorithm calculates the greatest common divisor (GCD) of two number a and b. The greatest common divisor g is the largest natural number that divides both a and b without leaving a remainder. Synonyms for the GCD include the greatest common factor (GCF), the highest common factor (HCF), the highest common divisor (HCD), … Continue reading Java Program to Implement Euclid GCD Algorithm using Recursion

Java program to find factorial of given number using recursion

Recursion  is a method where the solution to a problem depends on solutions to smaller instances of the same problem.One of the classic problems for introducing recursion is calculating the factorial of an integer. The factorial of any given integer — call it n  — is the product of all the integers from 1 to … Continue reading Java program to find factorial of given number using recursion