<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Fakultät Hilfe]]></title><description><![CDATA[<pre><code class="language-cpp">long double fakult1(unsigned int n)   // Iterative Berechnung
{
   long double ergebnis = 1.0;
   for( unsigned int i = 2; i &lt;= n; ++i)
       ergebnis *= i;

   return ergebnis;
}

long double fakult2(unsigned int n)   // Rekursive Berechnung
{
   if( n &lt;= 1)
      return 1.0;
   else
      return fakult2(n-1) * n;
}
</code></pre>
<p>könnt ihr mir bitte helfen, wie der code schritt für schritt ablauft?<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133176/fakultät-hilfe</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 19:04:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133176.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Jan 2006 20:28:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fakultät Hilfe on Sun, 15 Jan 2006 20:28:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">long double fakult1(unsigned int n)   // Iterative Berechnung
{
   long double ergebnis = 1.0;
   for( unsigned int i = 2; i &lt;= n; ++i)
       ergebnis *= i;

   return ergebnis;
}

long double fakult2(unsigned int n)   // Rekursive Berechnung
{
   if( n &lt;= 1)
      return 1.0;
   else
      return fakult2(n-1) * n;
}
</code></pre>
<p>könnt ihr mir bitte helfen, wie der code schritt für schritt ablauft?<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/967515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/967515</guid><dc:creator><![CDATA[anfängerc++]]></dc:creator><pubDate>Sun, 15 Jan 2006 20:28:47 GMT</pubDate></item><item><title><![CDATA[Reply to Fakultät Hilfe on Sun, 15 Jan 2006 20:49:31 GMT]]></title><description><![CDATA[<p>zeig doch mal, was du schon hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/967542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/967542</guid><dc:creator><![CDATA[c.rackwitz]]></dc:creator><pubDate>Sun, 15 Jan 2006 20:49:31 GMT</pubDate></item><item><title><![CDATA[Reply to Fakultät Hilfe on Sun, 15 Jan 2006 20:54:03 GMT]]></title><description><![CDATA[<p>iterativ:<br />
startwert nehmen, dann rinn in die schleife, zum ergebnis 2 multiplizieren und neien wert in ergebnis speichern, dann schleife -&gt;3. ergebnis (wo schon das produkt 1*2 drinsteht, mit 3 multiplizieren , dann in ergebnis speichern (=6), nächster schleifenaufruf ... usw ... bis n eben.</p>
<p>rekursiv:<br />
z.b. übergibste 5, dann wird 5 multipliziert mit fak(4). fak(4) lässt sich noch nicht berechnen, da da auch wieder der funktionsaufruf drinsteht.<br />
bis jetzt haste also:<br />
5<em>fak(4)<br />
= 5*4*fak(3)<br />
=5*4*3</em>fak(2)<br />
=5*4*3*2*fak(1)<br />
fak(1) ist bekannt, nämlich 1.<br />
jetzt weiß damit fak(2), dass sie 2*1 rechnen muss, fak(3) rechnet dann fak(2)=(1*2) *3 usw...<br />
geht von unten wieder hoch, bis die letzte funktion, also die zuerst aufgerufen wurde (nämlich fak(5) ihren wert zurückgibt - fertig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/967546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/967546</guid><dc:creator><![CDATA[ethereal]]></dc:creator><pubDate>Sun, 15 Jan 2006 20:54:03 GMT</pubDate></item><item><title><![CDATA[Reply to Fakultät Hilfe on Sun, 15 Jan 2006 20:58:08 GMT]]></title><description><![CDATA[<p>anfängerc++ schrieb:</p>
<blockquote>
<p>könnt ihr mir bitte helfen, wie der code schritt für schritt ablauft?<br />
danke</p>
</blockquote>
<p>fakult1 berechnet die Fakultät nach der einfachen und vermutlich bekannteren Methode:</p>
<p>n! = 1 * 2 * ... * n</p>
<p>Recht viel mehr fällt mir dazu ned ein.</p>
<p>fakult2 verwendet einen rekursiven Ansatz:</p>
<p>1! = 1;<br />
n! = n * (n - 1)!</p>
<p>Bsp:<br />
3! = 3 * (3 - 1)! = 3 * 2!<br />
2! = 2 * (2 - 1)! = 2 * 1! = 2 * 1;</p>
<p>=&gt; 3! = 3 * 2 * 1;</p>
<p>[edit]<br />
zu spät<br />
[/edit]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/967547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/967547</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Sun, 15 Jan 2006 20:58:08 GMT</pubDate></item></channel></rss>