From 2553a75d6311b2d946f24f8d26a923e20e969452 Mon Sep 17 00:00:00 2001 From: Arceus-sj <71997730+Arceus-sj@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:33:05 +0530 Subject: [PATCH 01/25] Add files via upload --- C++/PrintSeries.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 C++/PrintSeries.cpp diff --git a/C++/PrintSeries.cpp b/C++/PrintSeries.cpp new file mode 100644 index 00000000..08392ff3 --- /dev/null +++ b/C++/PrintSeries.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +void printSeries(int num1,int num2){ + int count = 1; + int i = 1; + while(count < num1+1){ + int num = (3 * i) + 2; + i++; + + if((num % num2) == 0){ + + }else{ + cout<>num1>>num2; + printSeries(num1,num2); + return 0; +} \ No newline at end of file From cf8f562ca21b341e2cf6244d7a043fa69f95001d Mon Sep 17 00:00:00 2001 From: Arceus-sj <71997730+Arceus-sj@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:39:41 +0530 Subject: [PATCH 02/25] Create Readme.md --- C++/Program18/Readme.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 C++/Program18/Readme.md diff --git a/C++/Program18/Readme.md b/C++/Program18/Readme.md new file mode 100644 index 00000000..9118f569 --- /dev/null +++ b/C++/Program18/Readme.md @@ -0,0 +1,33 @@ +## Problem + +```bash +Write a function which prints first num1 terms of the series 3n+2 which are not multiples of num2. +``` + +## Take Input +```bash +Number 1(num1) +Number 2(num2) +0 < num1 < 100 & 0 < num2 < 100 +``` + +## Sample Input + +```bash +num1 = 10; +num2 = 4; +``` +## Sample Output + +```bash +5 +11 +14 +17 +23 +26 +29 +35 +38 +41 +``` From 3137892ef6b1dcb24f697b5189be2664defda3b9 Mon Sep 17 00:00:00 2001 From: Arceus-sj <71997730+Arceus-sj@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:55:21 +0530 Subject: [PATCH 03/25] Rename C++/PrintSeries.cpp to C++/Program18/PrintSeries.cpp --- C++/{ => Program18}/PrintSeries.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename C++/{ => Program18}/PrintSeries.cpp (93%) diff --git a/C++/PrintSeries.cpp b/C++/Program18/PrintSeries.cpp similarity index 93% rename from C++/PrintSeries.cpp rename to C++/Program18/PrintSeries.cpp index 08392ff3..efb8b7f7 100644 --- a/C++/PrintSeries.cpp +++ b/C++/Program18/PrintSeries.cpp @@ -24,4 +24,4 @@ int main() cin>>num1>>num2; printSeries(num1,num2); return 0; -} \ No newline at end of file +} From 2561c6543d427289634eb0603ffd9ebb9b3b9c5e Mon Sep 17 00:00:00 2001 From: Mayanksingla139 <55097726+Mayanksingla139@users.noreply.github.com> Date: Fri, 16 Oct 2020 00:20:05 +0530 Subject: [PATCH 04/25] Read me # To check whether a number is in palindrome or not --- C++/program-19 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 C++/program-19 diff --git a/C++/program-19 b/C++/program-19 new file mode 100644 index 00000000..a18f2dd0 --- /dev/null +++ b/C++/program-19 @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int num, temp, digit, rev = 0; + + cout << "Enter a positive number: "; + cin >> num; + temp = num; + while (num != 0){ + digit = num % 10; + rev = (rev * 10) + digit; + num = num / 10; + } + cout << "The reverse of the number is: " << rev << endl; + if (temp == rev){ + cout<<"The number is a palindrome."; + } + else{ + cout << "The number is not a palindrome."; + } + return 0; +} From cca9858568d4bb9932479613bebfce8f5c6fca09 Mon Sep 17 00:00:00 2001 From: Mayanksingla139 <55097726+Mayanksingla139@users.noreply.github.com> Date: Fri, 16 Oct 2020 00:24:12 +0530 Subject: [PATCH 05/25] Delete program-19 --- C++/program-19 | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 C++/program-19 diff --git a/C++/program-19 b/C++/program-19 deleted file mode 100644 index a18f2dd0..00000000 --- a/C++/program-19 +++ /dev/null @@ -1,23 +0,0 @@ -#include -using namespace std; -int main() -{ - int num, temp, digit, rev = 0; - - cout << "Enter a positive number: "; - cin >> num; - temp = num; - while (num != 0){ - digit = num % 10; - rev = (rev * 10) + digit; - num = num / 10; - } - cout << "The reverse of the number is: " << rev << endl; - if (temp == rev){ - cout<<"The number is a palindrome."; - } - else{ - cout << "The number is not a palindrome."; - } - return 0; -} From e731e4136b853a539adad278267a4fc0d38f688b Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Fri, 16 Oct 2020 00:55:17 +0530 Subject: [PATCH 06/25] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 0a5ec0fd..32191b66 100644 --- a/readme.md +++ b/readme.md @@ -115,5 +115,5 @@ ### Tada you just made a contribution โœจ. Pat your back ๐Ÿ‘

-### If you have never made a PR before ๐Ÿ˜•, no worries, follow these steps to get going [๐Ÿ‘‰click me](https://gitme.js.org/) +### If you have never made a PR before ๐Ÿ˜•, no worries, follow these steps to get going [๐Ÿ‘‰click me](https://gitgo.swaaz.me/) From 3dec8861c9de008814e2746d78d11b201cf559f5 Mon Sep 17 00:00:00 2001 From: Mayanksingla139 Date: Fri, 16 Oct 2020 10:16:34 +0530 Subject: [PATCH 07/25] To check whether a number is in palindrome or not --- C++/README.md | 1 + C++/program-19/Read me.md | 1 + C++/program-19/palindrome.cpp | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 C++/program-19/Read me.md create mode 100644 C++/program-19/palindrome.cpp diff --git a/C++/README.md b/C++/README.md index 6c2a8fec..4ffbcb51 100644 --- a/C++/README.md +++ b/C++/README.md @@ -15,3 +15,4 @@ | Program-10 | Program to find the missing number in a Sorted Array. | Program-15 | Program to find modular exponentiation. +| Program-19| To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/Read me.md b/C++/program-19/Read me.md new file mode 100644 index 00000000..a952e91a --- /dev/null +++ b/C++/program-19/Read me.md @@ -0,0 +1 @@ +# To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/palindrome.cpp b/C++/program-19/palindrome.cpp new file mode 100644 index 00000000..a18f2dd0 --- /dev/null +++ b/C++/program-19/palindrome.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int num, temp, digit, rev = 0; + + cout << "Enter a positive number: "; + cin >> num; + temp = num; + while (num != 0){ + digit = num % 10; + rev = (rev * 10) + digit; + num = num / 10; + } + cout << "The reverse of the number is: " << rev << endl; + if (temp == rev){ + cout<<"The number is a palindrome."; + } + else{ + cout << "The number is not a palindrome."; + } + return 0; +} From 419d1e126011febaae8ea7a87cc1d030c44c1ead Mon Sep 17 00:00:00 2001 From: Shravya R Shetty <67235369+Shravyarshetty@users.noreply.github.com> Date: Fri, 16 Oct 2020 22:17:07 +0530 Subject: [PATCH 08/25] Update README.md --- Python/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index c1b29aee..c5696bfa 100644 --- a/Python/README.md +++ b/Python/README.md @@ -21,4 +21,14 @@ | Program-17 | Program to convert Binary to Decimal. | | Program-18 | Program to check leap year or not. | | Program-19 | Program to count number of integers between 1 to 50 divisible by a number. | -| Program-20 | Program to create an array of range specified and print. | \ No newline at end of file +| Program-20 | Program to create an array of range specified and print. | +| Program-21 | Program to print the number of *. | +| Program-22 | Program to check if a number is even or odd | +| Program-23 | Program to find the all the prime numbers between the given range. | +| Program-24 | Program to convert binary number to decimal | +| Program-25 | Program to sort the array and give the time to sort the array. | +| Program-26 | Program to print a right angled triangle. | +| Program-27 | Program to convert Binary to Decimal. | +| Program-28 | Program to check leap year or not. | +| Program-29 | Program to count number of integers between 1 to 50 divisible by a number. | +| Program-30 | Program to create an array of range specified and print. | From 28a6bac231bc555bcc6a35d6cc9babfd272708f2 Mon Sep 17 00:00:00 2001 From: Shravya R Shetty <67235369+Shravyarshetty@users.noreply.github.com> Date: Fri, 16 Oct 2020 22:24:46 +0530 Subject: [PATCH 09/25] Update README.md --- Python/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Python/README.md b/Python/README.md index c5696bfa..bc55403d 100644 --- a/Python/README.md +++ b/Python/README.md @@ -26,9 +26,10 @@ | Program-22 | Program to check if a number is even or odd | | Program-23 | Program to find the all the prime numbers between the given range. | | Program-24 | Program to convert binary number to decimal | -| Program-25 | Program to sort the array and give the time to sort the array. | -| Program-26 | Program to print a right angled triangle. | -| Program-27 | Program to convert Binary to Decimal. | -| Program-28 | Program to check leap year or not. | +| Program-25 | Program of a car game which shows if the car has started or stopped | +| Program-26 | Program of a guessing game in which u guess the secret number with a guessing limit of 3 attempts. | +| Program-27 | Program which tells you the of downpayment of the house is 10% or 20% +depending if the owner has a good credit or not.The price of the house is to be entered in the output | +| Program-28 | Program to find out the GCD of any 2 given numbers | | Program-29 | Program to count number of integers between 1 to 50 divisible by a number. | | Program-30 | Program to create an array of range specified and print. | From 8c2efab50b11f0aacbc0ef4d7752dc371b13dcbf Mon Sep 17 00:00:00 2001 From: Shravya R Shetty <67235369+Shravyarshetty@users.noreply.github.com> Date: Fri, 16 Oct 2020 22:28:07 +0530 Subject: [PATCH 10/25] Update README.md --- Python/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index bc55403d..b171790f 100644 --- a/Python/README.md +++ b/Python/README.md @@ -31,5 +31,5 @@ | Program-27 | Program which tells you the of downpayment of the house is 10% or 20% depending if the owner has a good credit or not.The price of the house is to be entered in the output | | Program-28 | Program to find out the GCD of any 2 given numbers | -| Program-29 | Program to count number of integers between 1 to 50 divisible by a number. | -| Program-30 | Program to create an array of range specified and print. | +| Program-29 | Program which will display the fibonacci series | +| Program-31 | Program to print Amstrong numbers | From b56d4d4a2bdfbdf48cdf9b1d3c986b2eb1216cf9 Mon Sep 17 00:00:00 2001 From: Sitikanta-Panigrahi <60188244+Sitispeaks@users.noreply.github.com> Date: Sat, 17 Oct 2020 14:34:38 +0530 Subject: [PATCH 11/25] Create square_root_using_binary_search.cpp A cpp code to find the square root of a given number using binary search --- .../square_root_using_binary_search.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 C++/Program-20/square_root_using_binary_search.cpp diff --git a/C++/Program-20/square_root_using_binary_search.cpp b/C++/Program-20/square_root_using_binary_search.cpp new file mode 100644 index 00000000..53f78f47 --- /dev/null +++ b/C++/Program-20/square_root_using_binary_search.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + + +float square_root(int num,int p) { + int s=0; + int e=num; + float ans=-1; + while(s<=e) { + int mid=s+e>>1; // (s+e)/2 + if(mid*mid==num) { + return mid; + } + else if(mid*mid>=num) { + e=mid-1; + + } + else { //as 7*7 is vey close to 50 + s=mid+1; + ans=mid; + } + } + + //for floating part + //brute force + float inc=0.1; + for(int i=1;i<=p;i++) { + while(ans*ans<=num) { + ans=ans+inc; + } + //when this blows up + ans=ans-inc;//comeback 1 step + inc/=10; + } + return ans; + +} + +int main() { + int num,p; + cin>>num;///the input number of which you want to find the square root + cin>>p;//find the square root upto "p" no of places + cout< Date: Sat, 17 Oct 2020 14:37:42 +0530 Subject: [PATCH 12/25] Create Readme.md --- C++/Program-20/Readme.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 C++/Program-20/Readme.md diff --git a/C++/Program-20/Readme.md b/C++/Program-20/Readme.md new file mode 100644 index 00000000..31029063 --- /dev/null +++ b/C++/Program-20/Readme.md @@ -0,0 +1,4 @@ +To find the square root of a number upto "p" no of places + + +Here we take input of that number "num" and the number "p" From 20737567878800b397e99ff58e061b254d1eea7c Mon Sep 17 00:00:00 2001 From: Sitikanta-Panigrahi <60188244+Sitispeaks@users.noreply.github.com> Date: Sat, 17 Oct 2020 14:39:49 +0530 Subject: [PATCH 13/25] Rename square_root_using_binary_search.cpp to program.cpp A cpp program to find the square root of a number upto "p" number of places --- .../{square_root_using_binary_search.cpp => program.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename C++/Program-20/{square_root_using_binary_search.cpp => program.cpp} (100%) diff --git a/C++/Program-20/square_root_using_binary_search.cpp b/C++/Program-20/program.cpp similarity index 100% rename from C++/Program-20/square_root_using_binary_search.cpp rename to C++/Program-20/program.cpp From 136155cc120dbebfb17a8fb89693d909f640b456 Mon Sep 17 00:00:00 2001 From: Sitikanta-Panigrahi <60188244+Sitispeaks@users.noreply.github.com> Date: Sat, 17 Oct 2020 14:43:54 +0530 Subject: [PATCH 14/25] Update and rename Readme.md to README.md --- C++/Program-20/{Readme.md => README.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename C++/Program-20/{Readme.md => README.md} (50%) diff --git a/C++/Program-20/Readme.md b/C++/Program-20/README.md similarity index 50% rename from C++/Program-20/Readme.md rename to C++/Program-20/README.md index 31029063..6a94fd2d 100644 --- a/C++/Program-20/Readme.md +++ b/C++/Program-20/README.md @@ -1,4 +1,4 @@ -To find the square root of a number upto "p" no of places +## To find the square root of a number upto "p" no of places Here we take input of that number "num" and the number "p" From be7900884e65d454e038a4c1ab33207552124814 Mon Sep 17 00:00:00 2001 From: Anju Kumari Date: Sun, 18 Oct 2020 11:59:55 +0530 Subject: [PATCH 15/25] A program in Dart --- Dart/Program1/checkevenodd.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dart/Program1/checkevenodd.dart diff --git a/Dart/Program1/checkevenodd.dart b/Dart/Program1/checkevenodd.dart new file mode 100644 index 00000000..0259ae75 --- /dev/null +++ b/Dart/Program1/checkevenodd.dart @@ -0,0 +1,14 @@ +import 'dart:io'; + +void main() { + int number; + + print("Enter a number : "); + number = int.parse(stdin.readLineSync()); + + if (number.isEven) { + print("$number is an even number"); + } else if (number.isOdd) { + print("$number is an odd number"); + } +} \ No newline at end of file From b43f37fad83b91712b36c6b61da6a6335ef8f739 Mon Sep 17 00:00:00 2001 From: Anju Kumari <42924677+Anju1415@users.noreply.github.com> Date: Sun, 18 Oct 2020 12:54:07 +0530 Subject: [PATCH 16/25] Create README.md Question Added --- Dart/Program1/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Dart/Program1/README.md diff --git a/Dart/Program1/README.md b/Dart/Program1/README.md new file mode 100644 index 00000000..9d3d8f2b --- /dev/null +++ b/Dart/Program1/README.md @@ -0,0 +1,3 @@ +Q1. Write a program to check given number is even or odd. + +Ask the number from user in variable "number" From 2e74c9037c179b3817443de038ded52aae419b29 Mon Sep 17 00:00:00 2001 From: Gowtham PB <67544642+GowthamPB@users.noreply.github.com> Date: Wed, 21 Oct 2020 22:58:42 +0530 Subject: [PATCH 17/25] Updated README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index b171790f..21cda4fc 100644 --- a/Python/README.md +++ b/Python/README.md @@ -32,4 +32,4 @@ depending if the owner has a good credit or not.The price of the house is to be entered in the output | | Program-28 | Program to find out the GCD of any 2 given numbers | | Program-29 | Program which will display the fibonacci series | -| Program-31 | Program to print Amstrong numbers | +| Program-30 | Program to print Amstrong numbers | From 3562bb1e228863b57f32d1b72784be5612836ef5 Mon Sep 17 00:00:00 2001 From: Gowtham PB <67544642+GowthamPB@users.noreply.github.com> Date: Wed, 21 Oct 2020 23:02:36 +0530 Subject: [PATCH 18/25] Updated readme file --- Python/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index 21cda4fc..313454a0 100644 --- a/Python/README.md +++ b/Python/README.md @@ -32,4 +32,5 @@ depending if the owner has a good credit or not.The price of the house is to be entered in the output | | Program-28 | Program to find out the GCD of any 2 given numbers | | Program-29 | Program which will display the fibonacci series | -| Program-30 | Program to print Amstrong numbers | +| Program-30 | Program to make simple calculator | +| Program-31 | Program to print Amstrong numbers | From eb4f4ef8ca8ded2e2d3e523237d16b14c6e872a7 Mon Sep 17 00:00:00 2001 From: "Gowtham.P.B" Date: Wed, 21 Oct 2020 23:24:18 +0530 Subject: [PATCH 19/25] Added Program 30 --- Python/Program 30/README.md | 3 +++ Python/Program 30/program.py | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Python/Program 30/README.md create mode 100644 Python/Program 30/program.py diff --git a/Python/Program 30/README.md b/Python/Program 30/README.md new file mode 100644 index 00000000..d941c707 --- /dev/null +++ b/Python/Program 30/README.md @@ -0,0 +1,3 @@ +Program 30 + +Program to make a simple calculator diff --git a/Python/Program 30/program.py b/Python/Program 30/program.py new file mode 100644 index 00000000..414ef65e --- /dev/null +++ b/Python/Program 30/program.py @@ -0,0 +1,48 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # Take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # Check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + break + else: + print("Invalid Input") \ No newline at end of file From 55afa9f19667dcdc0fa3c2db02b8235cee11a16a Mon Sep 17 00:00:00 2001 From: "Gowtham.P.B" Date: Wed, 21 Oct 2020 23:44:58 +0530 Subject: [PATCH 20/25] Added program 70 in C folder --- C/program-70/README.md | 3 +++ C/program-70/program70.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 C/program-70/README.md create mode 100644 C/program-70/program70.c diff --git a/C/program-70/README.md b/C/program-70/README.md new file mode 100644 index 00000000..0b00a221 --- /dev/null +++ b/C/program-70/README.md @@ -0,0 +1,3 @@ +Program 70 + +C program to make simple calculator \ No newline at end of file diff --git a/C/program-70/program70.c b/C/program-70/program70.c new file mode 100644 index 00000000..8b90c5bf --- /dev/null +++ b/C/program-70/program70.c @@ -0,0 +1,38 @@ +#include + int main() + { + char op; + float number1,number2,result; + for(int i=0; i<5;i++) + { + printf("\nEnter\n + for Addition \n - for Subtraction \n * for Multiplication \n / for Division"); + printf("\nEnter the operation you want to perform\n"); + scanf("%s",&op); + printf("Enter two numbers\n"); + scanf("%f %f",&number1,&number2); + switch(op) + { + case'+':result=number1+number2; + printf("Sum is %f\n",result); + break; + case'-':result=number1-number2; + printf("Difference is %f\n",result); + break; + case'*':result=number1*number2; + printf("Product is %f\n",result); + break; + case'/':if(number2==0) + { + printf("Division not possible\n"); + } + else + { + result=number1/number2; + printf("Quotient is %f\n",result); + } + break; + default:printf("Enter proper input\n"); + } + } + return 0; + } \ No newline at end of file From 51a18a9738a8637ed32fa67419058aed1b426bd5 Mon Sep 17 00:00:00 2001 From: Gowtham PB <67544642+GowthamPB@users.noreply.github.com> Date: Thu, 22 Oct 2020 00:02:50 +0530 Subject: [PATCH 21/25] Updated readme file --- C/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C/README.md b/C/README.md index 2fb8a86b..8a0b269a 100644 --- a/C/README.md +++ b/C/README.md @@ -71,3 +71,4 @@ | Program-67 | Program to calulate all the prime between the range of numbers includes the numbers which is provided. | | Program-68 | Program to accept 0s and 1s as input and print if it consists 3 consecutive 0s | | Program-69 | Program to find strong number | +| Program-70 | Program to make a simple calculator | From c5feea8355a86d2ffd86a43854cf289b951547cb Mon Sep 17 00:00:00 2001 From: Nirali Sahoo <58680652+nizz009@users.noreply.github.com> Date: Fri, 23 Oct 2020 12:27:17 +0530 Subject: [PATCH 22/25] Uploaded program-21 Addition of Program-21 in C++ directory which aims to find the last digit of partial Fibonacci Series. --- C++/Program-21/README.md | 26 ++++++++++++++++++++++++++ C++/Program-21/program.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 C++/Program-21/README.md create mode 100644 C++/Program-21/program.cpp diff --git a/C++/Program-21/README.md b/C++/Program-21/README.md new file mode 100644 index 00000000..82aa3347 --- /dev/null +++ b/C++/Program-21/README.md @@ -0,0 +1,26 @@ +#Last digit of sum of partial Fibonacci Series + +##Problem statement: +Given two non-negative integers m and n, where m <= n, find the last digit of the sum *Fm + Fm+1 + .... + Fn* + +###Input: +Two non negative intergers m and n, such that m <= n. + +###Output: +The last digit of the sum of Fibonacci series starting from *Fm* to *Fn*. + +###Example: + +*Input:* +``` +3 7 +``` +*Output:* +``` +1 +``` +*Explanation:* +``` +๐น3 + ๐น4 + ๐น5 + ๐น6 + ๐น7 = 2 + 3 + 5 + 8 + 13 = 31 +Last digit of 31 = 1 +``` diff --git a/C++/Program-21/program.cpp b/C++/Program-21/program.cpp new file mode 100644 index 00000000..52bd1d2d --- /dev/null +++ b/C++/Program-21/program.cpp @@ -0,0 +1,37 @@ +/* Compute the last digit of the sum of partial Fibonacci series. (Given two non-negative integers m and n, where m <= n, find the last digit of the sum Fm + Fm+1 + .... + Fn) */ + +#include +using namespace std; +typedef long long int ll; + +void solve() +{ + ll n = 0, m = 0; + int b[60] = {0, 1, 2, 4, 7, 2, 0, 3, 4, 8, 3, 2, 6, 9, 6, 6, 3, 0, 4, 5, 0, 6, 7, 4, 2, 7, 0, 8, 9, 8, 8, 7, 6, 4, 1, 6, 8, 5, 4, 0, 5, 6, 2, 9, 2, 2, 5, 8, 4, 3, 8, 2, 1, 4, 6, 1, 8, 0, 9, 0}; + int i = 0, j = 0, sum = 0; + + cin >> n >> m; + + i = (n-1) % 60; + j = m % 60; + + if(b[j] >= b[i]) + { + cout << b[j] - b[i] << "\n"; + } + else + { + b[j] += 10; + cout << b[j] - b[i] << "\n"; + } +} + +int main() +{ + //for fast input output + ios_base::sync_with_stdio(false);cin.tie(NULL); + + solve(); + + return 0; +} \ No newline at end of file From cd0fb12c9a2a9ec74ff184e9bd7839fecca36fc2 Mon Sep 17 00:00:00 2001 From: Nirali Sahoo <58680652+nizz009@users.noreply.github.com> Date: Fri, 23 Oct 2020 12:28:02 +0530 Subject: [PATCH 23/25] Update README.md --- C++/Program-21/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C++/Program-21/README.md b/C++/Program-21/README.md index 82aa3347..2b4cfbeb 100644 --- a/C++/Program-21/README.md +++ b/C++/Program-21/README.md @@ -1,15 +1,15 @@ -#Last digit of sum of partial Fibonacci Series +# Last digit of sum of partial Fibonacci Series -##Problem statement: +## Problem statement: Given two non-negative integers m and n, where m <= n, find the last digit of the sum *Fm + Fm+1 + .... + Fn* -###Input: +### Input: Two non negative intergers m and n, such that m <= n. -###Output: +### Output: The last digit of the sum of Fibonacci series starting from *Fm* to *Fn*. -###Example: +### Example: *Input:* ``` From b9265e35929aaa40328b52b13969b542fe129191 Mon Sep 17 00:00:00 2001 From: Abhishek Jasiwal <73077352+b419007@users.noreply.github.com> Date: Sat, 24 Oct 2020 15:04:46 +0530 Subject: [PATCH 24/25] Added Binary String Addition Algorithm The easiest and Optimised Way of adding up the two binary Number --- C++/Program 22/adding_two_string.cpp | 59 ++++++++++++++++++++++++++++ C++/Program 22/readme.md | 3 ++ 2 files changed, 62 insertions(+) create mode 100644 C++/Program 22/adding_two_string.cpp create mode 100644 C++/Program 22/readme.md diff --git a/C++/Program 22/adding_two_string.cpp b/C++/Program 22/adding_two_string.cpp new file mode 100644 index 00000000..68c0b973 --- /dev/null +++ b/C++/Program 22/adding_two_string.cpp @@ -0,0 +1,59 @@ +/* +Program : To add 2 string + +this Program is Contributed by Abhishek Jaiswal +*/ + +#include +using namespace std; + +int Len(string &str1, string &str2) +{ + int len1 = str1.size(); + int len2 = str2.size(); + if (len1 < len2) + { + for (int i = 0 ; i < len2 - len1 ; i++) + str1 = '0' + str1; + return len2; + } + else if (len1 > len2) + { + for (int i = 0 ; i < len1 - len2 ; i++) + str2 = '0' + str2; + } + return len1; +} + +string add( string a, string b ) +{ + string result; + int len = Len(a, b); + + int carry = 0; + for (int i = len-1 ; i >= 0 ; i--) + { + int aBit = a.at(i) - '0'; + int bBit = b.at(i) - '0'; + int sum = (aBit ^ bBit ^ carry)+'0'; + + result = (char)sum + result; + carry = (aBit & bBit) | (bBit & carry) | (aBit & carry); + } + + if (carry) + result = '1' + result; + + return result; +} + +int main() +{ + string str1,str2; + cout<<"Enter the string 1 :"; + cin>>str1; + cout<<"Enter the string 2 :"; + cin>>str2; + cout << "Sum is " << add(str1, str2); + return 0; +} diff --git a/C++/Program 22/readme.md b/C++/Program 22/readme.md new file mode 100644 index 00000000..1144c04b --- /dev/null +++ b/C++/Program 22/readme.md @@ -0,0 +1,3 @@ +Program : To add Two Binary Number +Input : Two Number consitising of 0 and 1 +Output : Number Constisting of 0 and 1 From 9dd036e0c1e696fc1b4c72d9562927c5be20f1f9 Mon Sep 17 00:00:00 2001 From: Abhishek Jasiwal <73077352+b419007@users.noreply.github.com> Date: Sat, 24 Oct 2020 16:52:01 +0530 Subject: [PATCH 25/25] Added of Sum the square of Binomial Number Added Easiest and Simplest way to Sum the square of Binomial Number --- C++/Program 23/readme.md | 4 +++ .../sum_of_square_of_binomial_coefficient.cpp | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 C++/Program 23/readme.md create mode 100644 C++/Program 23/sum_of_square_of_binomial_coefficient.cpp diff --git a/C++/Program 23/readme.md b/C++/Program 23/readme.md new file mode 100644 index 00000000..33afe4b7 --- /dev/null +++ b/C++/Program 23/readme.md @@ -0,0 +1,4 @@ +Program :To find the sum of square of binomial coefficient +Input : Integer +Output : Integer + diff --git a/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp b/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp new file mode 100644 index 00000000..032034db --- /dev/null +++ b/C++/Program 23/sum_of_square_of_binomial_coefficient.cpp @@ -0,0 +1,32 @@ +/* +Program :To find the sum of square of +binomial coefficient. + +This Program is contributed by Abhishek Jaiswal +*/ +#include +using namespace std; + +int factorial(int begin, int end) +{ + int num = 1; + for (int i = begin; i <= end; i++) + num *= i; + + return num; +} + +int square(int n) +{ + return factorial(n + 1, 2 * n) / factorial(1, n); +} + +int main() +{ + int n; + cout << "Enter the number :"; + cin >> n; + cout << "The Sum of Square is " << square(n) << endl; + return 0; +} +