Guest User

Untitled

a guest
Jan 8th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Diagnostics;
  5.  
  6. namespace PE29
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Stopwatch sw = new Stopwatch();
  13.             sw.Start();
  14.             List<double> powers = new List<double>();
  15.             for (double i = 2; i <= 100; i++)
  16.             {
  17.                 for (double k = 2; k <= 100; k++)
  18.                 {
  19.                     powers.Add(Math.Pow(i, k));
  20.                 }
  21.             }
  22.             double[] discretePowers = powers.Distinct().ToArray();
  23.             sw.Stop();
  24.             Console.WriteLine("The total number of discrete powers is {0}.  Runtime is {1}ms.",
  25.                 discretePowers.Length, sw.ElapsedMilliseconds);
  26.             Console.ReadLine();
  27.            
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment