fork(7) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. CalculatePower(5, 3); // 125
  8. CalculatePower(8, 4); // 4096
  9. CalculatePower(6, 2); // 36
  10. }
  11.  
  12. private static long CalculatePower(int Number, int PowerOf) {
  13. long Result = Number;
  14. for (int i = PowerOf; i > 1; i--) {
  15. Result = (Result * Number);
  16. }
  17. Console.WriteLine(Result.ToString());
  18. return Result;
  19. }
  20. }
Success #stdin #stdout 0.01s 29672KB
stdin
Standard input is empty
stdout
125
4096
36