Advertisement
Spocoman

08. Math Power

Jan 24th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MathPower
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double num = double.Parse(Console.ReadLine());
  10.             int power = int.Parse(Console.ReadLine());
  11.  
  12.             RaiseToPower(num, power);
  13.         }
  14.  
  15.         static double RaiseToPower(double num, int power)
  16.         {
  17.             double print = num;
  18.             for (int i = 0; i < power - 1; i++)
  19.             {
  20.                 print *= num;
  21.             }
  22.             Console.WriteLine(print);
  23.             return (print);
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement