From 86e1ce7aea8e2a28d574124ded3e69cd3c334e71 Mon Sep 17 00:00:00 2001 From: Abir Date: Thu, 10 Oct 2019 01:17:44 +0530 Subject: [PATCH 1/5] Added Small multiple code in C++. --- Solutions/smallmultiple.cpp | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Solutions/smallmultiple.cpp diff --git a/Solutions/smallmultiple.cpp b/Solutions/smallmultiple.cpp new file mode 100644 index 0000000..a76ec06 --- /dev/null +++ b/Solutions/smallmultiple.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + +typedef long long int ll; + +int hcf(int a, int b) +{ + if (b == 0) + return a; + return hcf(b, a % b); +} + +ll lcm(int arr[], int n) +{ + + ll ans = arr[0]; + + + for (int i = 1; i < n; i++) + ans = (((arr[i] * ans)) / + (hcf(arr[i], ans))); + + return ans; +} + + +int main() +{ + int t; + cin>>t; + + while(t--) + { + int endterm; + + cin>>endterm; + int arr[endterm]; + for(int i=1;i<=endterm;i++) + arr[i-1]=i; + + int n = sizeof(arr) / sizeof(arr[0]); + printf("%lld", lcm(arr, n)); + } +return 0; +} From 923be1b206a509c719b3e993b9dcc4a2e9eaf5b1 Mon Sep 17 00:00:00 2001 From: Abir Date: Thu, 10 Oct 2019 17:40:32 +0530 Subject: [PATCH 2/5] Renamed smallmultiple.cpp to Smallest_multiple.cpp --- Solutions/{smallmultiple.cpp => Smallest_multiple.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Solutions/{smallmultiple.cpp => Smallest_multiple.cpp} (100%) diff --git a/Solutions/smallmultiple.cpp b/Solutions/Smallest_multiple.cpp similarity index 100% rename from Solutions/smallmultiple.cpp rename to Solutions/Smallest_multiple.cpp From 14643d5ed9610116c05ceef2b83dfc5ce1ca2b35 Mon Sep 17 00:00:00 2001 From: Abir Date: Thu, 10 Oct 2019 17:59:08 +0530 Subject: [PATCH 3/5] Added Solution to the respective question --- Solutions/Largest_prime_factor.cpp | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Solutions/Largest_prime_factor.cpp diff --git a/Solutions/Largest_prime_factor.cpp b/Solutions/Largest_prime_factor.cpp new file mode 100644 index 0000000..f3de15c --- /dev/null +++ b/Solutions/Largest_prime_factor.cpp @@ -0,0 +1,33 @@ +#include +#include +using namespace std; +long long LargestPrimeNumber(long long n) +{ + long long maxPrime = -1; + while (n % 2 == 0) { + maxPrime = 2; + n >>= 1; + } + for (int i = 3; i <= sqrt(n); i += 2) { + while (n % i == 0) { + maxPrime = i; + n = n / i; + } + } + if (n > 2) + maxPrime = n; + + return maxPrime; +} +int main() +{ + int t; + cin>>t; + while(t--) + { + long long n; + cin>>n; + cout << LargestPrimeNumber(n) << endl; + } + return 0; +} \ No newline at end of file From 891ad79741b3f77f7d8f4844d2d3ae45c94a5114 Mon Sep 17 00:00:00 2001 From: Abir Date: Thu, 10 Oct 2019 18:03:57 +0530 Subject: [PATCH 4/5] Update and rename Smallest_multiple.cpp to Smallest_multiple_(II).cpp --- Solutions/{Smallest_multiple.cpp => Smallest_multiple_(II).cpp} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Solutions/{Smallest_multiple.cpp => Smallest_multiple_(II).cpp} (90%) diff --git a/Solutions/Smallest_multiple.cpp b/Solutions/Smallest_multiple_(II).cpp similarity index 90% rename from Solutions/Smallest_multiple.cpp rename to Solutions/Smallest_multiple_(II).cpp index a76ec06..f17a265 100644 --- a/Solutions/Smallest_multiple.cpp +++ b/Solutions/Smallest_multiple_(II).cpp @@ -27,7 +27,7 @@ ll lcm(int arr[], int n) int main() { int t; - cin>>t; + scanf("%d",&t); while(t--) { From 8de434866dd236b4acae671da7337dff32ef9e38 Mon Sep 17 00:00:00 2001 From: Abir Date: Thu, 10 Oct 2019 22:13:43 +0530 Subject: [PATCH 5/5] Set theme jekyll-theme-architect --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..3397c9a --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file