Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pows
- {
- [STAThread]
- public static void Main(string[] args)
- {
- Console.Write("Enter a: ");
- int a = Convert.ToInt32(Console.ReadLine());
- Console.Write("Enter n: ");
- int n = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Answer: {0}" ,NegPow(a, n));
- }
- public static double NegPow(int a, int n)
- {
- return 1 / Pow(a, n);
- }
- public static double Pow(int a, int n)
- {
- if (n == 0) { return (1); }
- else return (a * Pow(a, --n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement