1. 幂次方
namespace Q1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0) return;
var n = int.Parse(textBox1.Text);
N.Text = n.ToString();
long[] a = { 1, 1,
1, 0 };
for (int i = 1; i < n; i++) a = calc(a, new long[]{
1, 1,
1, 0 });
A.Text = $"{a[0]:0}";
B.Text = $"{a[1]:0}";
C.Text = $"{a[2]:0}";
D.Text = $"{a[3]:0}";
}
// [0, 1]
// [2, 3]
long[] calc(long[] a, long[] b)
{
return new[] { a[0] * b[0] + a[1] * b[2], a[0] * b[1] + a[1] * b[3],
a[2]*b[0]+a[3]*b[2],a[2]*b[1]+a[3]*b[3]};
}
}
}Last updated