From 1c76beb0d4ccf57d2db84cf417f37a3a155fb905 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Sat, 26 May 2018 16:12:24 +0800 Subject: 58, 76, 97, 104 --- euler97.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 euler97.c (limited to 'euler97.c') diff --git a/euler97.c b/euler97.c new file mode 100644 index 0000000..b0f55bc --- /dev/null +++ b/euler97.c @@ -0,0 +1,30 @@ +#include + +static const unsigned char _7830457[3] = { 0x77, 0x7b, 0xb9 }; +static const unsigned char _2[1] = {2}; +static const unsigned char _28433[2] = {0x6f, 0x11}; +static const unsigned char _10000000000[5] = {0x02, 0x54, 0x0b, 0xe4, 0x00}; + +int main() +{ + BIGNUM *b28433 = BN_bin2bn(_28433, 2, NULL); + BIGNUM *b2 = BN_bin2bn(_2, 1, NULL); + BIGNUM *b7830457 = BN_bin2bn(_7830457, 3, NULL); + BIGNUM *b10ten = BN_bin2bn(_10000000000, 5, NULL); + + BN_CTX *ctx = BN_CTX_new(); + BIGNUM *r = BN_new(); + BIGNUM *r2 = BN_new(); + BIGNUM *r3 = BN_new(); + BN_mod_exp(r, b2, b7830457, b10ten, ctx); + BN_mul(r2, r, b28433, ctx); + BN_add(r3, r2, BN_value_one()); + BN_mod(r, r3, b10ten, ctx); + + unsigned char res[10]; + int len = BN_bn2mpi(r, res); + for (int i = 0; i < len; i++) + printf("%02x", res[i]); + + puts(""); +} -- cgit v1.2.3