Skip to content

Instantly share code, notes, and snippets.

@thomasw-mitutoyo-ctl
Created March 22, 2022 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasw-mitutoyo-ctl/acf8e4c4c1a098d7fd1fa34011174558 to your computer and use it in GitHub Desktop.
Save thomasw-mitutoyo-ctl/acf8e4c4c1a098d7fd1fa34011174558 to your computer and use it in GitHub Desktop.
Programmiere eine Funktion, die das gleiche Ergebnis liefert wie math.pow(), jedoch nur für Zahlen in N0
void main() {
print(pow(2,3));
print(pow(2,4));
print(pow(3,3));
print(pow(2,0));
}
int pow(int basis, int exponent)
{
int ergebnis = 1;
for (int i=0; i<exponent; i++)
{
ergebnis *= basis;
}
return ergebnis;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment