<?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[Hilfe zu Programm zum Berechnen von Potenzen]]></title><description><![CDATA[<p>Hallo<br />
bräuchte Hilfe beim Schreiben von einem Programm:</p>
<p>Es soll die Summe der Quadrate der ersten n positiven Ganzzahlen<br />
1² + 2² + 3² + ………n²<br />
berechnet werden,<br />
Nach jeder Eingabe wird das Ergebnis ausgegeben und danach die nächste Zahl n angefordert.</p>
<p>Hab noch kaum was mit C++ gemacht,wäre super wenn mir jemand helfen könnte.<br />
Vielen Dank schon mal im Vorraus</p>
<p>Sorry hatte mich verschrieben</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/237285/hilfe-zu-programm-zum-berechnen-von-potenzen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 13:31:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/237285.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Mar 2009 17:35:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 17:56:58 GMT]]></title><description><![CDATA[<p>Hallo<br />
bräuchte Hilfe beim Schreiben von einem Programm:</p>
<p>Es soll die Summe der Quadrate der ersten n positiven Ganzzahlen<br />
1² + 2² + 3² + ………n²<br />
berechnet werden,<br />
Nach jeder Eingabe wird das Ergebnis ausgegeben und danach die nächste Zahl n angefordert.</p>
<p>Hab noch kaum was mit C++ gemacht,wäre super wenn mir jemand helfen könnte.<br />
Vielen Dank schon mal im Vorraus</p>
<p>Sorry hatte mich verschrieben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686494</guid><dc:creator><![CDATA[ToniKukoc]]></dc:creator><pubDate>Thu, 26 Mar 2009 17:56:58 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 17:40:46 GMT]]></title><description><![CDATA[<p>frage nicht grade eindeutig. mach mal zwei oder drei durchläufe per hand und schreib hier, bei welchen eingaben welche ausgaben kommen sollten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686498</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 26 Mar 2009 17:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 18:15:45 GMT]]></title><description><![CDATA[<p>meinst du so etwas?</p>
<pre><code class="language-cpp">int ergebnis = 0;
for (int i = 1; i &lt;= n; i++)
   ergebnis = ergebnis + i*i;
</code></pre>
<p>&quot;ergebnis&quot; sollte nun die Summe alle Quadrate der gesamten natürlichen Zahlen bis n beinhalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686511</guid><dc:creator><![CDATA[nocheingast]]></dc:creator><pubDate>Thu, 26 Mar 2009 18:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 18:48:58 GMT]]></title><description><![CDATA[<p>Gauss hat da mal was als kleines Kind gemacht, so ohne Schleifen ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686538</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 26 Mar 2009 18:48:58 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 18:59:28 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Gauss hat da mal was als kleines Kind gemacht, so ohne Schleifen ...</p>
</blockquote>
<p>jaja vollständige Induktion:<br />
1/6n(n+1)*(2n+1)</p>
<p>will noch wer rekursion? *g*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686550</guid><dc:creator><![CDATA[nocheingast]]></dc:creator><pubDate>Thu, 26 Mar 2009 18:59:28 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:06:14 GMT]]></title><description><![CDATA[<p>nocheingast schrieb:</p>
<blockquote>
<p>knivil schrieb:</p>
<blockquote>
<p>Gauss hat da mal was als kleines Kind gemacht, so ohne Schleifen ...</p>
</blockquote>
<p>jaja vollständige Induktion:<br />
1/6n(n+1)*(2n+1)</p>
<p>will noch wer rekursion? *g*</p>
</blockquote>
<p>ja, ich.<br />
denn</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(n+2);
</code></pre>
<p>rechnet falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686555</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686555</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:06:14 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:17:54 GMT]]></title><description><![CDATA[<p>Im Tafelwerk muesste die Summe der ersten n-Quadratzahlen als explixite Formel drin stehen, bin mir grad net sicher ob Gauss die auch als Kind schon hergeleitet hat.</p>
<blockquote>
<p>ja, ich.<br />
denn</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(n+2);
</code></pre>
<p>rechnet falsch.</p>
</blockquote>
<p>Kein Wunder, es ist ja schon spaet. Probiers mal mit copy &amp; paste :).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686557</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:17:54 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:24:46 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>nocheingast schrieb:</p>
<blockquote>
<p>jaja vollständige Induktion:<br />
1/6n(n+1)*(2n+1)</p>
<p>will noch wer rekursion? *g*</p>
</blockquote>
<p>ja, ich.<br />
denn</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(n+2);
</code></pre>
<p>rechnet falsch.</p>
</blockquote>
<p>oh jo war zu dumm um abzuschreiben^^<br />
knivil hat die richtige formel... also statt &quot;(n+2)&quot; hätte da &quot;(2n+1)&quot; hingemusst.</p>
<p>rekursiv wäre es glaube dies hier:</p>
<pre><code class="language-cpp">int func(int n)
{
  if (n &lt;= 0)
    return 0;
  else
    return n*n + func(n-1); 
}
</code></pre>
<p>diesmal gab es nichts zum abschreiben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> trotzdem: ohne gewähr *g*</p>
<p>Aber zurück zur Frage.<br />
War dies dein gesuchtes Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686578</guid><dc:creator><![CDATA[nocheingast]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:24:46 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:29:06 GMT]]></title><description><![CDATA[<blockquote>
<p>knivil hat die richtige formel... also statt &quot;(n+2)&quot; hätte da &quot;(2n+1)&quot; hingemusst.</p>
</blockquote>
<p>Habe meine wieder rausgeloescht, da sie schon mal von &quot;nocheingast&quot; (dir?) gepostet wurde und volkhard mich verwirrt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686581</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:29:06 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:29:32 GMT]]></title><description><![CDATA[<p>ist es jetzt schlimm, daß</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(2*n+1);
</code></pre>
<p>auch falsch rechnet?<br />
c++ ist manchmal schon ne verrückte sprache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686584</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:29:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:32:18 GMT]]></title><description><![CDATA[<p>hab ich gesehen... nur hab ich gar nicht gesehen das ich es richtig eingetippt habe und kann nun nicht mehr editieren -.-<br />
(sollte mich hier anmelden).</p>
<p>dieses &quot;zu dumm um abzuschreiben&quot; war eigentlich auf mich bezogen, da ich dachte, ich hätte dir, volkard, die falsche formel geschickt, also bitte nicht falsch verstehen ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686587</guid><dc:creator><![CDATA[nocheingast]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:32:18 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:37:31 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>ist es jetzt schlimm, daß</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(2*n+1);
</code></pre>
<p>auch falsch rechnet?<br />
c++ ist manchmal schon ne verrückte sprache.</p>
</blockquote>
<p>Schlimm, schlimm ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686591</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:43:14 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>ist es jetzt schlimm, daß</p>
<pre><code class="language-cpp">int ergebnis = 1/6*n*(n+1)*(2*n+1);
</code></pre>
<p>auch falsch rechnet?<br />
c++ ist manchmal schon ne verrückte sprache.</p>
</blockquote>
<p>vllt eine Klammer um (1/6) bzw (n*(n+1)<em>(2</em>n+1)) / 6;?<br />
Ansonst hättest du ja als ergebnis einen ziemlich kleinen Bruch wenn es mich nicht täuscht</p>
<p>ansonst versuch mal:</p>
<pre><code class="language-cpp">int ergebnis =  n*(n+1)*(2*n+1);
ergebnis = ergebnis *1/6;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1686597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686597</guid><dc:creator><![CDATA[nocheinmitglied]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Thu, 26 Mar 2009 19:47:13 GMT]]></title><description><![CDATA[<p>die klammer brachte nix.<br />
aber wenn ich am ende des ausdrucks oder gar in der folgezeile erst duch 6 teile klappts. danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686603</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 26 Mar 2009 19:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe zu Programm zum Berechnen von Potenzen on Fri, 27 Mar 2009 12:46:27 GMT]]></title><description><![CDATA[<p>Vielen Dank,danach habe ich gesucht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1686919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1686919</guid><dc:creator><![CDATA[ToniKukoc]]></dc:creator><pubDate>Fri, 27 Mar 2009 12:46:27 GMT</pubDate></item></channel></rss>