© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
2 replies
KevToTo

Need help

    public static string CaesarTower(int n)
    {
        if (n < 1)
        {
            throw new ArgumentException();
        }
        int to;
        
        string res = $"Moves for {n} disks\n";
        int total = (int)Basix.MyPow(2, n) - 1;
        for (int i = 1; i <= total ; i++)
        {
            if (n%2==1)
            {
                res += (i & i - 1) % 3 + 1 + " -> " + (((i | i - 1) + 1) % 3                 + 1);
            }
            else
            {
              ...
            }
            if (i != total)
                res += "\n";
        }

        return res;
    public static string CaesarTower(int n)
    {
        if (n < 1)
        {
            throw new ArgumentException();
        }
        int to;
        
        string res = $"Moves for {n} disks\n";
        int total = (int)Basix.MyPow(2, n) - 1;
        for (int i = 1; i <= total ; i++)
        {
            if (n%2==1)
            {
                res += (i & i - 1) % 3 + 1 + " -> " + (((i | i - 1) + 1) % 3                 + 1);
            }
            else
            {
              ...
            }
            if (i != total)
                res += "\n";
        }

        return res;



My program works for all odd numbers, but I don't know how to make it work for all numbers
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

NEED HELP
C#CC# / help
17mo ago
need help
C#CC# / help
3y ago
✅ Need Help
C#CC# / help
3y ago
❔ Need Help
C#CC# / help
3y ago