TheAlgorithms-C/d4/d83/problem__401_2sol1_8c.html

355 lines
26 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: project_euler/problem_401/sol1.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C
&#160;<span id="projectnumber">1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('d4/d83/problem__401_2sol1_8c.html','../../'); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">sol1.c File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><a href="https://projecteuler.net/problem=401">Problem 401</a> solution - Sum of squares of divisors
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;time.h&gt;</code><br />
<code>#include &lt;inttypes.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for sol1.c:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/dd3/problem__401_2sol1_8c__incl.svg" width="436" height="127"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:aacbb9e1f38be71e22df1584a37c56693"><td class="memItemLeft" align="right" valign="top"><a id="aacbb9e1f38be71e22df1584a37c56693"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>__STDC_FORMAT_MACROS</b></td></tr>
<tr class="separator:aacbb9e1f38be71e22df1584a37c56693"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca7d5718ab8c38506adb3bef2469b319"><td class="memItemLeft" align="right" valign="top"><a id="aca7d5718ab8c38506adb3bef2469b319"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#aca7d5718ab8c38506adb3bef2469b319">MOD</a>&#160;&#160;&#160;(uint64_t)1e9</td></tr>
<tr class="memdesc:aca7d5718ab8c38506adb3bef2469b319"><td class="mdescLeft">&#160;</td><td class="mdescRight">modulo limit <br /></td></tr>
<tr class="separator:aca7d5718ab8c38506adb3bef2469b319"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf2a0717e3307419a9d7c52707f5631e"><td class="memItemLeft" align="right" valign="top"><a id="adf2a0717e3307419a9d7c52707f5631e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#adf2a0717e3307419a9d7c52707f5631e">MAX_L</a>&#160;&#160;&#160;5000</td></tr>
<tr class="memdesc:adf2a0717e3307419a9d7c52707f5631e"><td class="mdescLeft">&#160;</td><td class="mdescRight">chunk size of array allocation <br /></td></tr>
<tr class="separator:adf2a0717e3307419a9d7c52707f5631e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a4441a6d27134cf3aed05727800d99456"><td class="memItemLeft" align="right" valign="top">char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#a4441a6d27134cf3aed05727800d99456">is_in</a> (uint64_t <a class="el" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>, uint64_t *D, uint64_t <a class="el" href="../../df/db3/struct_l.html">L</a>)</td></tr>
<tr class="memdesc:a4441a6d27134cf3aed05727800d99456"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if a number is present in given array. <a href="../../d4/d83/problem__401_2sol1_8c.html#a4441a6d27134cf3aed05727800d99456">More...</a><br /></td></tr>
<tr class="separator:a4441a6d27134cf3aed05727800d99456"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7380e14d595d560007b02ce516b6b215"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#a7380e14d595d560007b02ce516b6b215">get_divisors</a> (uint64_t <a class="el" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>, uint64_t *D)</td></tr>
<tr class="memdesc:a7380e14d595d560007b02ce516b6b215"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get all integer divisors of a number. <a href="../../d4/d83/problem__401_2sol1_8c.html#a7380e14d595d560007b02ce516b6b215">More...</a><br /></td></tr>
<tr class="separator:a7380e14d595d560007b02ce516b6b215"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a236548478af932f1115a71f601a68788"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#a236548478af932f1115a71f601a68788">sigma2</a> (uint64_t <a class="el" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>)</td></tr>
<tr class="memdesc:a236548478af932f1115a71f601a68788"><td class="mdescLeft">&#160;</td><td class="mdescRight">compute sum of squares of all integer factors of a number <a href="../../d4/d83/problem__401_2sol1_8c.html#a236548478af932f1115a71f601a68788">More...</a><br /></td></tr>
<tr class="separator:a236548478af932f1115a71f601a68788"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf964739be92adc2f500e7da11e3f6be"><td class="memItemLeft" align="right" valign="top"><a id="aaf964739be92adc2f500e7da11e3f6be"></a>
uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#aaf964739be92adc2f500e7da11e3f6be">sigma</a> (uint64_t <a class="el" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>)</td></tr>
<tr class="memdesc:aaf964739be92adc2f500e7da11e3f6be"><td class="mdescLeft">&#160;</td><td class="mdescRight">sum of squares of factors of numbers from 1 thru N <br /></td></tr>
<tr class="separator:aaf964739be92adc2f500e7da11e3f6be"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3c04138a5bfe5d72780bb7e82a18e627"><td class="memItemLeft" align="right" valign="top"><a id="a3c04138a5bfe5d72780bb7e82a18e627"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a> (int argc, char **argv)</td></tr>
<tr class="memdesc:a3c04138a5bfe5d72780bb7e82a18e627"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <br /></td></tr>
<tr class="separator:a3c04138a5bfe5d72780bb7e82a18e627"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a href="https://projecteuler.net/problem=401">Problem 401</a> solution - Sum of squares of divisors </p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/kvedala">Krishna Vedala</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a7380e14d595d560007b02ce516b6b215"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7380e14d595d560007b02ce516b6b215">&#9670;&nbsp;</a></span>get_divisors()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint64_t get_divisors </td>
<td>(</td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>N</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t *&#160;</td>
<td class="paramname"><em>D</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get all integer divisors of a number. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">N</td><td>number to find divisors for </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">D</td><td>array to store divisors in </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of divisors found </dd></dl>
<div class="fragment"><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160;{</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; uint64_t q, r;</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; int64_t i, num = 0;</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> == 1)</div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; {</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; D[0] = 1;</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; }</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; </div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <span class="comment">// search till sqrt(N)</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="comment">// because after this, the pair of divisors will repeat themselves</span></div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <span class="keywordflow">for</span> (i = 1; i * i &lt;= <a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> + 1; i++)</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; {</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; r = <a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> % i; <span class="comment">// get reminder</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; </div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="comment">// reminder = 0 if &#39;i&#39; is a divisor of &#39;N&#39;</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; <span class="keywordflow">if</span> (r == 0)</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; {</div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; q = <a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a> / i;</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="keywordflow">if</span> (!<a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#a4441a6d27134cf3aed05727800d99456">is_in</a>(i, D, num)) <span class="comment">// if divisor was already stored</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; {</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; D[num] = i;</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; num++;</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; }</div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="keywordflow">if</span> (!<a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#a4441a6d27134cf3aed05727800d99456">is_in</a>(q, D, num)) <span class="comment">// if divisor was already stored</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; {</div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; D[num] = q;</div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; num++;</div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; }</div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; }</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <span class="keywordflow">if</span> (num == <a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#adf2a0717e3307419a9d7c52707f5631e">MAX_L</a>) <span class="comment">// limit of array reached, allocate more space</span></div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; D = (uint64_t *)realloc(D, <a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#adf2a0717e3307419a9d7c52707f5631e">MAX_L</a> * <span class="keyword">sizeof</span>(uint64_t) &lt;&lt; 1);</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; }</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <span class="keywordflow">return</span> num;</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d4/d83/problem__401_2sol1_8c_a7380e14d595d560007b02ce516b6b215_cgraph.svg" width="200" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a4441a6d27134cf3aed05727800d99456"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4441a6d27134cf3aed05727800d99456">&#9670;&nbsp;</a></span>is_in()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char is_in </td>
<td>(</td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>N</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t *&#160;</td>
<td class="paramname"><em>D</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>L</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Check if a number is present in given array. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">N</td><td>number to check </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">D</td><td>array to check </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname"><a class="el" href="../../df/db3/struct_l.html">L</a></td><td>length of array </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 if present </dd>
<dd>
0 if absent </dd></dl>
<div class="fragment"><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;{</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; uint64_t i;</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="../../df/db3/struct_l.html">L</a>; i++)</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <span class="keywordflow">if</span> (D[i] == <a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>)</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a236548478af932f1115a71f601a68788"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a236548478af932f1115a71f601a68788">&#9670;&nbsp;</a></span>sigma2()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint64_t sigma2 </td>
<td>(</td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>N</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>compute sum of squares of all integer factors of a number </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">N</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>sum of squares </dd></dl>
<div class="fragment"><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160;{</div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; uint64_t sum = 0, <a class="code" href="../../df/db3/struct_l.html">L</a>;</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; int64_t i;</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; uint64_t *D = (uint64_t *)malloc(<a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#adf2a0717e3307419a9d7c52707f5631e">MAX_L</a> * <span class="keyword">sizeof</span>(uint64_t));</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; </div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <a class="code" href="../../df/db3/struct_l.html">L</a> = <a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#a7380e14d595d560007b02ce516b6b215">get_divisors</a>(<a class="code" href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>, D);</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="keywordflow">for</span> (i = 1; i &lt; <a class="code" href="../../df/db3/struct_l.html">L</a>; i++)</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; {</div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; uint64_t DD = (D[i] * D[i]) % <a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#aca7d5718ab8c38506adb3bef2469b319">MOD</a>;</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; sum += DD;</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; }</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; </div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; free(D);</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="keywordflow">return</span> sum % <a class="code" href="../../d4/d83/problem__401_2sol1_8c.html#aca7d5718ab8c38506adb3bef2469b319">MOD</a>;</div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160;}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d4/d83/problem__401_2sol1_8c_a236548478af932f1115a71f601a68788_cgraph.svg" width="312" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="astruct_l_html"><div class="ttname"><a href="../../df/db3/struct_l.html">L</a></div><div class="ttdef"><b>Definition:</b> list.h:8</div></div>
<div class="ttc" id="aproblem__401_2sol1_8c_html_aca7d5718ab8c38506adb3bef2469b319"><div class="ttname"><a href="../../d4/d83/problem__401_2sol1_8c.html#aca7d5718ab8c38506adb3bef2469b319">MOD</a></div><div class="ttdeci">#define MOD</div><div class="ttdoc">modulo limit</div><div class="ttdef"><b>Definition:</b> sol1.c:17</div></div>
<div class="ttc" id="aproblem__401_2sol1_8c_html_a7380e14d595d560007b02ce516b6b215"><div class="ttname"><a href="../../d4/d83/problem__401_2sol1_8c.html#a7380e14d595d560007b02ce516b6b215">get_divisors</a></div><div class="ttdeci">uint64_t get_divisors(uint64_t N, uint64_t *D)</div><div class="ttdoc">Get all integer divisors of a number.</div><div class="ttdef"><b>Definition:</b> sol1.c:43</div></div>
<div class="ttc" id="aproblem__401_2sol1_8c_html_adf2a0717e3307419a9d7c52707f5631e"><div class="ttname"><a href="../../d4/d83/problem__401_2sol1_8c.html#adf2a0717e3307419a9d7c52707f5631e">MAX_L</a></div><div class="ttdeci">#define MAX_L</div><div class="ttdoc">chunk size of array allocation</div><div class="ttdef"><b>Definition:</b> sol1.c:18</div></div>
<div class="ttc" id="aproblem__13_2sol1_8c_html_a0240ac851181b84ac374872dc5434ee4"><div class="ttname"><a href="../../db/d01/problem__13_2sol1_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a></div><div class="ttdeci">#define N</div><div class="ttdoc">number of digits of the large number</div><div class="ttdef"><b>Definition:</b> sol1.c:109</div></div>
<div class="ttc" id="aproblem__401_2sol1_8c_html_a4441a6d27134cf3aed05727800d99456"><div class="ttname"><a href="../../d4/d83/problem__401_2sol1_8c.html#a4441a6d27134cf3aed05727800d99456">is_in</a></div><div class="ttdeci">char is_in(uint64_t N, uint64_t *D, uint64_t L)</div><div class="ttdoc">Check if a number is present in given array.</div><div class="ttdef"><b>Definition:</b> sol1.c:28</div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_b3d331eabd4234f247030c297aaf021c.html">project_euler</a></li><li class="navelem"><a class="el" href="../../dir_2f070f19f76dfadabbc24fe483d7e98d.html">problem_401</a></li><li class="navelem"><a class="el" href="../../d4/d83/problem__401_2sol1_8c.html">sol1.c</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.18 </li>
</ul>
</div>
</body>
</html>