morry2341

LazyPower

Oct 30th, 2022
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Net;
  6. using System.Linq;
  7.  
  8. namespace ConsoleApp1
  9. {
  10.     public class Program { public static void Main() {
  11.  
  12.             foreach (double d in Pow(2, 16))
  13.             {
  14.                 Console.WriteLine("Power: " + d);
  15.             }
  16.  
  17.         }
  18.  
  19.         public static IEnumerable<double> Pow(double baseNumber, int exponentNumber)
  20.         {
  21.             double currentPower;
  22.             for (double i = 0; i < exponentNumber; i++)
  23.             {
  24.                 currentPower = Math.Pow(baseNumber, exponentNumber);
  25.                 yield return currentPower;
  26.                 break;
  27.             }
  28.  
  29.         }
  30.     }
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment