Challenge: Distinct Powers

Posted on: August 23, 2017 10:17:27 PM

Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:

22=4, 23=8, 24=16, 25=32
32=9, 33=27, 34=81, 35=243
42=16, 43=64, 44=256, 45=1024
52=25, 53=125, 54=625, 55=3125

If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?

This was very straight forward for me. The most simple way to do this is a simple brute force option. There are ways to calculate out most of the duplicates, but those calculations end up taking longer than 2 simple loops and feed the results into a hashset to guarantee uniqueness to get the answer.
Program.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Project_Euler_29
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Stopwatch sw = Stopwatch.StartNew();
            HashSet<double> results = new HashSet<double>();

            for (int a = 2; a <= 100; a++)
            {
                for (int b = 2; b <= 100; b++)
                {
                    results.Add(Math.Pow(a, b));
                }
            }

            sw.Stop();

            Console.WriteLine($"Number of distinct powers: {results.Count}");
            Console.WriteLine($"Took {sw.ElapsedMilliseconds}ms");
        }
    }
}

Comments


hiv gay chat san diego [url="https://chatcongays.com"]gay chat room cam[/url] free gay chat line

GenniesrPa September 15, 2022 11:37:45 PM

free mens gay and bi chat lines seattle wa [url="https://chatcongays.com"]gay chat recorded[/url] gay chat the ave

GenniesrPa September 16, 2022 2:51:01 AM

cheap essay writing service online [url="https://au-bestessays.org"]help in writing an essay[/url] community service essay sample

MarrissrPa September 20, 2022 12:26:24 AM

writing essay services [url="https://au-bestessays.org"]essay writing service[/url] professional essay help

MarrissrPa September 20, 2022 12:47:31 AM

best essays writing service [url="https://bestcampusessays.com"]need help to write an essay[/url] national honor society essay help

DorolisasrPa September 20, 2022 7:40:22 PM

custom essay services [url="https://bestcampusessays.com"]essay on service[/url] need help writing scholarship essay

DorolisasrPa September 20, 2022 8:00:12 PM

easy essay help [url="https://besteasyessays.org"]help on writing an essay[/url] rutgers essay help

MartysrPa September 21, 2022 5:59:42 PM

medical school essay help [url="https://besteasyessays.org"]help with writing college essays[/url] cheapest essay writing services

MartysrPa September 21, 2022 6:21:11 PM

english literature essay help [url="https://bestessayreviews.net"]top 10 essay writing services[/url] hire essay writer

MerolasrPa September 22, 2022 1:55:56 PM

help me to write an essay [url="https://bestessayreviews.net"]english essay writing service[/url] help with writing essay

MerolasrPa September 22, 2022 2:19:19 PM

pay for someone to write my essay [url="https://bestessaysden.com"]custom essay company[/url] help with writing an essay

AshlensrPa September 23, 2022 9:43:18 AM

fast essay writing service [url="https://bestessaysden.com"]write my admission essay[/url] write my essay generator

AshlensrPa September 23, 2022 10:05:41 AM

college application essay help online [url="https://bestsessays.org"]affordable essay writing service[/url] legit essay writing services

CharitasrPa September 24, 2022 11:20:20 PM

urgent custom essays [url="https://bestsessays.org"]hire essay writer[/url] custome essay

CharitasrPa September 24, 2022 11:41:07 PM

buy essay [url="https://buyacademicessay.com"]essay writer website[/url] college application essay service

NanicesrPa September 25, 2022 6:19:10 PM

cheap essay online [url="https://buyacademicessay.com"]do my essay for me cheap[/url] best college essay help

NanicesrPa September 25, 2022 6:39:25 PM

essay help pros [url="https://buy-eessay-online.com"]help me write essay[/url] essay writing service review

ChelsaesrPa September 26, 2022 1:58:27 PM

best essay writer service [url="https://buy-eessay-online.com"]professional essay editing service[/url] buy an essay online cheap

ChelsaesrPa September 26, 2022 2:19:30 PM

best online essay editing service [url="https://buytopessays.com"]buy cheap essay online[/url] pay for someone to write my essay

PennysrPa September 27, 2022 9:06:31 AM

help writing a comparison and contrast essay [url="https://buytopessays.com"]the help essay prompts[/url] can i get someone to write my essay

PennysrPa September 27, 2022 9:28:34 AM

custome essay [url="https://cheapessaywritingservice1.com"]essay writing service law[/url] personal essay writers

TammiesrPa September 28, 2022 4:58:46 AM

argument essay help [url="https://cheapessaywritingservice1.com"]pay to write my essay[/url] custome essay

TammiesrPa September 28, 2022 5:18:28 AM

auto essay writer [url="https://customcollegeessays.net"]college admission essay service[/url] buy college essays online

AntoniesrPa September 29, 2022 12:55:51 AM

essay writing websites [url="https://customcollegeessays.net"]automatic essay writer[/url] custom essays cheap

AntoniesrPa September 29, 2022 1:14:56 AM

best college essay writing services [url="https://customessays-writing.org"]essay on the help[/url] admissions essay help

RhiamonsrPa September 29, 2022 8:35:15 PM

essay writer service [url="https://customessays-writing.org"]top rated essay writing services[/url] cheap custom essay papers

RhiamonsrPa September 29, 2022 8:54:08 PM

pay you to write my essay [url="https://customessaywwriting.com"]national junior honor society essay help[/url] best essay writing service website

CharosrPa September 30, 2022 3:27:19 PM

essay writers [url="https://customs-essays-writing.org"]best essays[/url] custom essay org

DronasrPa October 1, 2022 10:02:35 AM

essay on customer service [url="https://firstessayservice.net"]essay on social service[/url] cheap essay help online

TwylasrPa October 2, 2022 5:32:26 AM

best essay help review [url="https://firstessayservice.net"]essay writer reddit[/url] buy essays online cheap

TwylasrPa October 2, 2022 5:52:34 AM

expository essay help [url="https://geniusessaywriters.net"]essay writing company reviews[/url] how to be a better essay writer

LeilahsrPa October 3, 2022 2:17:39 AM

essay writers service [url="https://geniusessaywriters.net"]help writing college essays[/url] custom essay service

LeilahsrPa October 3, 2022 2:37:52 AM

good essay writing company [url="https://howtobuyanessay.com"]cheap custom essays[/url] custom essay service

CthrinesrPa October 4, 2022 12:31:47 AM

good essay writing websites [url="https://lawessayhelpinlondon.com"]help with an essay[/url] cheap essay service

GinniesrPa October 9, 2022 12:05:27 PM

college essay proofreading service [url="https://lawessayhelpinlondon.com"]cheapest essays writing services[/url] please help me write my essay

GinniesrPa October 9, 2022 12:25:13 PM

high school essay help [url="https://ukessayservice.net"]high school essay help[/url] service essay

VivienesrPa October 11, 2022 6:25:51 PM

the help essay [url="https://ukessayservice.net"]college essay writing services[/url] essay conclusion help

VivienesrPa October 11, 2022 6:45:59 PM

college application essay writers [url="https://writemyessaycheap24h.com"]custom essays writing[/url] essay help sites

EastersrPa October 13, 2022 9:24:55 AM

law school essay editing service [url="https://writemyessaycheap24h.com"]good essay writing websites[/url] good essay writing websites

EastersrPa October 13, 2022 9:46:24 AM

https://prednisoneall.top/

UrcESBT October 31, 2022 6:13:17 AM

https://prednisoneall.top/

SonNHGR November 1, 2022 3:17:38 AM

custom essay org [url="https://bestcampusessays.com"]i need someone to write my essay[/url] help me write a essay

DorolisasrPa November 19, 2022 6:09:25 AM

essay service [url="https://bestessayreviews.net"]essay on service to humanity[/url] best custom essays

MerolasrPa November 21, 2022 8:56:59 PM

online essay helper [url="https://bestsessays.org"]service essays[/url] write my history essay for me

CharitasrPa November 24, 2022 1:30:42 PM

college essay writers [url="https://buyacademicessay.com"]someone write my essay[/url] cheap custom essay

NanicesrPa November 25, 2022 10:49:27 PM

best college essay writing services [url="https://buy-eessay-online.com"]top ten essay writing services[/url] custom essay writers

ChelsaesrPa November 27, 2022 8:10:42 AM

write my essay 4 me [url="https://buytopessays.com"]write my essay cheap[/url] write my essay help

PennysrPa November 28, 2022 5:18:22 PM

essay on service [url="https://buytopessays.com"]buy essay writing[/url] good essay writing services

PennysrPa November 28, 2022 5:50:57 PM

striplife.ru

Elma February 1, 2023 7:55:48 PM

Leave a Comment