Deprecated: Return type of Dotenv\Repository\AbstractRepository::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php on line 147

Deprecated: Return type of Dotenv\Repository\AbstractRepository::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php on line 155

Deprecated: Return type of Dotenv\Repository\AbstractRepository::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php on line 163

Deprecated: Return type of Dotenv\Repository\AbstractRepository::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php on line 171

Deprecated: Return type of PhpOption\Some::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/phpoption/phpoption/src/PhpOption/Some.php on line 151

Deprecated: Return type of PhpOption\None::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/forthrig/public_html/wp-content/plugins/anycomment/vendor/phpoption/phpoption/src/PhpOption/None.php on line 118
CPPS Archives | forthright48 https://forthright48.com/category/cpps/ learning never ends Tue, 05 Nov 2019 15:42:50 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.8 Sum of Co-prime Numbers of an Integer https://forthright48.com/sum-of-coprime-numbers-of-integer/?utm_source=rss&utm_medium=rss&utm_campaign=sum-of-coprime-numbers-of-integer https://forthright48.com/sum-of-coprime-numbers-of-integer/#comments Fri, 07 Dec 2018 19:54:01 +0000 https://forthright48.com/?p=596 Problem Given a number $N$, find the sum of all numbers less than or equal to $N$ that are co-prime with $N$. In case you forgot, a number $x$ is co-prime with $N$ if $gcd(x,N) = 1$. For example, if $N = 10$, then the following numbers are co-prime with it: $[1, 3, 7, 9]$. …

The post Sum of Co-prime Numbers of an Integer appeared first on forthright48.

]]>
https://forthright48.com/sum-of-coprime-numbers-of-integer/feed/ 7
GCD Sum Function https://forthright48.com/gcd-sum-function/?utm_source=rss&utm_medium=rss&utm_campaign=gcd-sum-function https://forthright48.com/gcd-sum-function/#respond Sun, 25 Nov 2018 17:38:44 +0000 https://forthright48.com/?p=502 Problem Given a positive integer $N$, find the value of $g(N)$, where $$g(n) = gcd(1,n) + gcd(2,n) + gcd(3,n) + \dots + gcd(n,n) = \sum_{i=1}^n gcd(i,n)$$ For example, $$ \begin{align} g(6) & = gcd(1,6) + gcd(2,6) + g(3,6) + gcd(4,6) + gcd(5,6) + gcd(6,6) \\ & = 1 + 2 + 3 + 2 + …

The post GCD Sum Function appeared first on forthright48.

]]>
https://forthright48.com/gcd-sum-function/feed/ 0
Multiplicative Function https://forthright48.com/multiplicative-function/?utm_source=rss&utm_medium=rss&utm_campaign=multiplicative-function https://forthright48.com/multiplicative-function/#respond Sat, 24 Nov 2018 09:56:53 +0000 https://forthright48.com/?p=439 A function $f(n)$ is called multiplicative function if: $f(n)$ is defined for positive integer $n$. $f(1) = 1$ $f(mn) = f(m)f(n)$ whenever $gcd(m,n) = 1$. For example, the following functions are multiplicative: Euler Phi – $\phi(n)$ Number of Divisor – $\sigma_0(n)$ Sum of Divisor – $\sigma_1(n)$ Divisor Sum Theorem of Multiplicative Function Theorem: Let $f(n)$ …

The post Multiplicative Function appeared first on forthright48.

]]>
https://forthright48.com/multiplicative-function/feed/ 0
SPOJ ASCDFIB – Ascending Fibonacci Numbers https://forthright48.com/spoj-ascdfib-ascending-fibonacci-numbers/?utm_source=rss&utm_medium=rss&utm_campaign=spoj-ascdfib-ascending-fibonacci-numbers https://forthright48.com/spoj-ascdfib-ascending-fibonacci-numbers/#respond Thu, 22 Nov 2018 14:51:40 +0000 https://forthright48.com/?p=422 SPOJ ASCDFIB – Ascending Fibonacci Numbers is one of the earliest problems I created. This problem was used in one of the internal contests of Daffodil University. I was aiming for an easy, but a tricky problem and thus the following problem was created. Problem Read the complete description of the problem from SPOJ ASCDFIB …

The post SPOJ ASCDFIB – Ascending Fibonacci Numbers appeared first on forthright48.

]]>
https://forthright48.com/spoj-ascdfib-ascending-fibonacci-numbers/feed/ 0
Lucas Theorem – Proof and Applications https://forthright48.com/lucas-theorem-proof-and-applications/?utm_source=rss&utm_medium=rss&utm_campaign=lucas-theorem-proof-and-applications https://forthright48.com/lucas-theorem-proof-and-applications/#comments Fri, 16 Nov 2018 08:48:24 +0000 https://forthright48.com/?p=352 Problem Given non-negative integers $N$, $K$ and a prime number $P$, find the value of: $$\binom{N}{K} \mod P$$ Sounds like a simple problem right? There are several ways to solve the problem, depending on the constraints of $N$, $K$, and $P$. Direct: If $N$, $K$ are really small, less than $12$, then we can calculate …

The post Lucas Theorem – Proof and Applications appeared first on forthright48.

]]>
https://forthright48.com/lucas-theorem-proof-and-applications/feed/ 1
Stars and Bars Theorem https://forthright48.com/stars-and-bars-theorem/?utm_source=rss&utm_medium=rss&utm_campaign=stars-and-bars-theorem https://forthright48.com/stars-and-bars-theorem/#respond Sun, 23 Sep 2018 15:32:54 +0000 https://forthright48.com/?p=307 Problem Given K variables, $a_1, a_2, a_3 \dots a_K$ and a value $N$, how many ways can we write $a_1 + a_2 + a_3 \dots a_K = N$, where $a_1, a_2, a_3 \dots a_K$ are non-negative integers? For example, if $K = 3$ and $N=2$, there are 6 solutions. a b c ----- 2 0 …

The post Stars and Bars Theorem appeared first on forthright48.

]]>
https://forthright48.com/stars-and-bars-theorem/feed/ 0
Application of Prufer Code: Random Tree Generation, Cayley’s Formula and Building Tree from Degree Count https://forthright48.com/application-of-prufer-code-random-tree-generation-cayleys-formula-and-building-tree-from-degree-count/?utm_source=rss&utm_medium=rss&utm_campaign=application-of-prufer-code-random-tree-generation-cayleys-formula-and-building-tree-from-degree-count https://forthright48.com/application-of-prufer-code-random-tree-generation-cayleys-formula-and-building-tree-from-degree-count/#respond Thu, 08 Feb 2018 09:55:00 +0000 On the last post (Prufer Code: Linear Representation of a Labeled Tree), we discussed how to convert a labeled tree into Prufer Code and vice versa. On this post, we will look into some of its applications in problem-solving. Generating Random Tree This one is the simplest. Though problem-solving may not require generating random trees, …

The post Application of Prufer Code: Random Tree Generation, Cayley’s Formula and Building Tree from Degree Count appeared first on forthright48.

]]>
https://forthright48.com/application-of-prufer-code-random-tree-generation-cayleys-formula-and-building-tree-from-degree-count/feed/ 0
Prufer Code: Linear Representation of a Labeled Tree https://forthright48.com/prufer-code-linear-representation-of-a-labeled-tree/?utm_source=rss&utm_medium=rss&utm_campaign=prufer-code-linear-representation-of-a-labeled-tree https://forthright48.com/prufer-code-linear-representation-of-a-labeled-tree/#comments Sun, 28 Jan 2018 19:02:00 +0000 I guess this is going to be my first post (apart from the contest analysis’) which is not about Number Theory! It’s not about graph either, even though the title has “Tree” in it. This post is actually about Combinatorics. Prufer code, in my opinion, is one of the most underrated algorithms I have learned. …

The post Prufer Code: Linear Representation of a Labeled Tree appeared first on forthright48.

]]>
https://forthright48.com/prufer-code-linear-representation-of-a-labeled-tree/feed/ 2
Chinese Remainder Theorem Part 2 – Non Coprime Moduli https://forthright48.com/chinese-remainder-theorem-part-2-non-coprime-moduli/?utm_source=rss&utm_medium=rss&utm_campaign=chinese-remainder-theorem-part-2-non-coprime-moduli https://forthright48.com/chinese-remainder-theorem-part-2-non-coprime-moduli/#respond Sat, 18 Nov 2017 17:39:00 +0000 As promised on the last post, today we are going to discuss the “Strong Form” of Chinese Remainder Theorem, i.e, what do we do when the moduli in the congruence equations are not pairwise coprime. The solution is quite similar to the one we have already discussed in the previous post, so hopefully, it will …

The post Chinese Remainder Theorem Part 2 – Non Coprime Moduli appeared first on forthright48.

]]>
https://forthright48.com/chinese-remainder-theorem-part-2-non-coprime-moduli/feed/ 0
Chinese Remainder Theorem Part 1 – Coprime Moduli https://forthright48.com/chinese-remainder-theorem-part-1-coprime-moduli/?utm_source=rss&utm_medium=rss&utm_campaign=chinese-remainder-theorem-part-1-coprime-moduli https://forthright48.com/chinese-remainder-theorem-part-1-coprime-moduli/#comments Wed, 15 Nov 2017 13:17:00 +0000 Second part of the series can be found on: Chinese Remainder Theorem Part 2 – Non Coprime Moduli Wow. It has been two years since I published my last post. Time sure flies by quickly. I have been thinking about resuming writing again for a while now. Took me long enough to get back into …

The post Chinese Remainder Theorem Part 1 – Coprime Moduli appeared first on forthright48.

]]>
https://forthright48.com/chinese-remainder-theorem-part-1-coprime-moduli/feed/ 4