Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class Pows
  2. {
  3. [STAThread]
  4. public static void Main(string[] args)
  5. {
  6. Console.Write("Enter a: ");
  7. int a = Convert.ToInt32(Console.ReadLine());
  8.  
  9. Console.Write("Enter n: ");
  10. int n = Convert.ToInt32(Console.ReadLine());
  11.  
  12. Console.WriteLine("Answer: {0}" ,NegPow(a, n));
  13. }
  14.  
  15. public static double NegPow(int a, int n)
  16. {
  17. return 1 / Pow(a, n);
  18. }
  19.  
  20. public static double Pow(int a, int n)
  21. {
  22. if (n == 0) { return (1); }
  23. else return (a * Pow(a, --n));
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement