How to use BigInteger in C#

2 Answers

0 votes
using System.Numerics;

namespace WinFormsApp1 
{
    public partial class Form1 : Form
    {
    public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BigInteger a = new BigInteger(1);
            BigInteger b = new BigInteger(2);
            BigInteger c = new BigInteger(3);

            a = b << (3000 - 1);

            MessageBox.Show("a: " + a);
            MessageBox.Show("b: " + b);
            MessageBox.Show("c: " + c);
        }
    }
}



/*
run:

a: 1230231922161117176931558813276752514640713895736833715766118029160058800614672948775360067838593459582429649254051804908512884180898236823585082482065348331234959350355845017413023320111360666922624728239756880416434478315693675013413090757208690376793296658810662941824493488451726505303712916005346747908623702673480919353936813105736620402352744776903840477883651100322409301983488363802930540482487909763484098253940728685132044408863734754271212592471778643949486688511721051561970432780747454823776808464180697103083861812184348565522740195796682622205511845512080552010310050255801589349645928001133745474220715013683413907542779063759833876101354235184245096670042160720629411581502371248008430447184842098610320580417992206662247328722122088513643683907670360209162653670641130936997002170500675501374723998766005827579300723253474890612250135171889174899079911291512399773872178519018229989376
b: 2
c: 3
 
*/

 



answered Jun 9, 2024 by avibootz
0 votes
using System.Numerics;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BigInteger x = BigInteger.Pow(3, 242);

            MessageBox.Show("x = " + x);
        }
    }
}


/*
run:
 
x = 29063214161986986067637023528620257232321357468243916695175073145996989031241146647825183302277227705597018408555209

*/

 



answered May 6, 2025 by avibootz

Related questions

1 answer 191 views
1 answer 108 views
1 answer 117 views
1 answer 108 views
108 views asked Jun 9, 2024 by avibootz
1 answer 106 views
106 views asked Jun 9, 2024 by avibootz
1 answer 110 views
...