Documentation for 53a6c16730

This commit is contained in:
github-actions
2022-01-16 16:05:19 +00:00
parent 778f1be9e5
commit 2cab28c905
3620 changed files with 52045 additions and 41188 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: math/check_amicable_pair.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -157,9 +157,9 @@ Functions</h2></td></tr>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the pair is amicable </dd>
<dd>
<code>false</code> if the pair is not amicable </dd></dl>
<div class="fragment"><div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">return</span> (<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ac656a51b4c3bd7d63b7dcc75dc3e5576">sum_of_divisor</a>(x) == y) &amp;&amp; (<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ac656a51b4c3bd7d63b7dcc75dc3e5576">sum_of_divisor</a>(y) == x);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 48</span> {</div>
<div class="line"><span class="lineno"> 49</span> <span class="keywordflow">return</span> (<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ac656a51b4c3bd7d63b7dcc75dc3e5576">sum_of_divisor</a>(x) == y) &amp;&amp; (<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ac656a51b4c3bd7d63b7dcc75dc3e5576">sum_of_divisor</a>(y) == x);</div>
<div class="line"><span class="lineno"> 50</span>}</div>
<div class="ttc" id="acheck__amicable__pair_8cpp_html_ac656a51b4c3bd7d63b7dcc75dc3e5576"><div class="ttname"><a href="../../d5/df6/check__amicable__pair_8cpp.html#ac656a51b4c3bd7d63b7dcc75dc3e5576">sum_of_divisor</a></div><div class="ttdeci">int sum_of_divisor(int num)</div><div class="ttdef"><b>Definition:</b> check_amicable_pair.cpp:21</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -186,11 +186,11 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Main Function </p>
<div class="fragment"><div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a>();</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Assertion Success.&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 68</span> {</div>
<div class="line"><span class="lineno"> 69</span> <a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a>();</div>
<div class="line"><span class="lineno"> 70</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Assertion Success.&quot;</span> &lt;&lt; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 72</span>}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="acheck__amicable__pair_8cpp_html_ae1a3968e7947464bee7714f6d43b7002"><div class="ttname"><a href="../../d5/df6/check__amicable__pair_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a></div><div class="ttdeci">void test()</div><div class="ttdef"><b>Definition:</b> check_amicable_pair.cpp:56</div></div>
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
@@ -225,25 +225,25 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Sum of the proper divisor of the number. </dd></dl>
<div class="fragment"><div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> {</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> <span class="comment">// Variable to store the sum of all proper divisors.</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> <span class="keywordtype">int</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> = 0;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// Below loop condition helps to reduce Time complexity by a factor of</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> <span class="comment">// square root of the number.</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> div = 2; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> &lt;= num; ++<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>) {</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <span class="comment">// Check &#39;div&#39; is divisor of &#39;num&#39;.</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> <span class="keywordflow">if</span> (num % div == 0) {</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> <span class="comment">// If both divisor are same, add once to &#39;sum&#39;</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keywordflow">if</span> (div == (num / div)) {</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> += <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <span class="comment">// If both divisor are not the same, add both to &#39;sum&#39;.</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> += (<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> + (num / <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>));</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> }</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> }</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> }</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> + 1;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 21</span> {</div>
<div class="line"><span class="lineno"> 22</span> <span class="comment">// Variable to store the sum of all proper divisors.</span></div>
<div class="line"><span class="lineno"> 23</span> <span class="keywordtype">int</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> = 0;</div>
<div class="line"><span class="lineno"> 24</span> <span class="comment">// Below loop condition helps to reduce Time complexity by a factor of</span></div>
<div class="line"><span class="lineno"> 25</span> <span class="comment">// square root of the number.</span></div>
<div class="line"><span class="lineno"> 26</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> div = 2; <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> &lt;= num; ++<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>) {</div>
<div class="line"><span class="lineno"> 27</span> <span class="comment">// Check &#39;div&#39; is divisor of &#39;num&#39;.</span></div>
<div class="line"><span class="lineno"> 28</span> <span class="keywordflow">if</span> (num % div == 0) {</div>
<div class="line"><span class="lineno"> 29</span> <span class="comment">// If both divisor are same, add once to &#39;sum&#39;</span></div>
<div class="line"><span class="lineno"> 30</span> <span class="keywordflow">if</span> (div == (num / div)) {</div>
<div class="line"><span class="lineno"> 31</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> += <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>;</div>
<div class="line"><span class="lineno"> 32</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 33</span> <span class="comment">// If both divisor are not the same, add both to &#39;sum&#39;.</span></div>
<div class="line"><span class="lineno"> 34</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> += (<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a> + (num / <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/div.html">div</a>));</div>
<div class="line"><span class="lineno"> 35</span> }</div>
<div class="line"><span class="lineno"> 36</span> }</div>
<div class="line"><span class="lineno"> 37</span> }</div>
<div class="line"><span class="lineno"> 38</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">sum</a> + 1;</div>
<div class="line"><span class="lineno"> 39</span>}</div>
<div class="ttc" id="adiv_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/div.html">std::div</a></div><div class="ttdeci">T div(T... args)</div></div>
<div class="ttc" id="anamespacemachine__learning_html_a6f1c98c016ad34ff3d9f39372161bd35"><div class="ttname"><a href="../../d8/d77/namespacemachine__learning.html#a6f1c98c016ad34ff3d9f39372161bd35">machine_learning::sum</a></div><div class="ttdeci">T sum(const std::vector&lt; std::valarray&lt; T &gt; &gt; &amp;A)</div><div class="ttdef"><b>Definition:</b> vector_ops.hpp:232</div></div>
</div><!-- fragment --><div class="dynheader">
@@ -270,14 +270,14 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Function for testing the is_amicable() with all the test cases. </p>
<div class="fragment"><div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> {</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="comment">// are_amicable(220, 284) returns true.</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(220, 284) == <span class="keyword">true</span>);</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="comment">// are_amicable(6232, 6368) returns true.</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(6368, 6232) == <span class="keyword">true</span>);</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="comment">// are_amicable(458, 232) returns false.</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(458, 232) == <span class="keyword">false</span>);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 56</span> {</div>
<div class="line"><span class="lineno"> 57</span> <span class="comment">// are_amicable(220, 284) returns true.</span></div>
<div class="line"><span class="lineno"> 58</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(220, 284) == <span class="keyword">true</span>);</div>
<div class="line"><span class="lineno"> 59</span> <span class="comment">// are_amicable(6232, 6368) returns true.</span></div>
<div class="line"><span class="lineno"> 60</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(6368, 6232) == <span class="keyword">true</span>);</div>
<div class="line"><span class="lineno"> 61</span> <span class="comment">// are_amicable(458, 232) returns false.</span></div>
<div class="line"><span class="lineno"> 62</span> assert(<a class="code hl_function" href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a>(458, 232) == <span class="keyword">false</span>);</div>
<div class="line"><span class="lineno"> 63</span>}</div>
<div class="ttc" id="acheck__amicable__pair_8cpp_html_afeb67e204ec7de02ad152c11df4d1e01"><div class="ttname"><a href="../../d5/df6/check__amicable__pair_8cpp.html#afeb67e204ec7de02ad152c11df4d1e01">are_amicable</a></div><div class="ttdeci">bool are_amicable(int x, int y)</div><div class="ttdef"><b>Definition:</b> check_amicable_pair.cpp:48</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -294,7 +294,7 @@ Here is the call graph for this function:</div>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../d5/df6/check__amicable__pair_8cpp.html">check_amicable_pair.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>