./num.c
#include
#include
#include
#include
#include
#include
#include “ybn.h”
char *moduli[] = {
“282739864683854176474708222358620674431”,
“8175238263715229660254277872425441482375129331787917454150472572140723”
“9131801”,
“1047225273540272187235681029362917435187132422848678378910843942328779”
“6735787116381891200273193135579946798905605944933163063413182947233430”
“560022738618973”,
“9876240452241145411201795164150863919700805980375357087572344075242311”
“3934797645154705219681671715897201765128620387491142772245835421535872”
“7696628133189896591513069425405606675520981650673035496757751441037697”
“5974164932400781495627403581474782720560924652525435427883661142936817”
“1368270404679763247057669807”,
“2427385266227814870460145273746473135618474419005109512648317621444279”
“6042896639895023751227662272005196041977602344191882283488171821837975”
“1399737024369049023441062505098980870732961054274236102320211786990888”
“9597506356132128691728039767841436487994941683182014713021941210002638”
“5379392149633474438338885487400716751438540743657982045778325156736191”
“5406906467031263224569120176541077669630161147444546640030812048377572”
“0057387017237606153999300046104557719496551962988505943495636612621093”
“6226671479159150075183786138039199514373111999459116843133429798421654”
“1040178920649842391234553224499556085708345959830158924061842929905992”
“524842051826084307187276411544372265504650309211091074619”,
“3669729120294195081444998485551975344499521168008487165666162377296890”
“6898762286186089715451809632953950093670780393652069707515406575672534”
“8988983713971445775943132119492918909073182700701894941360834992255332”
“5816074933959086323164536340191279309476626719317693405254620336589005”
“6967513475182706249744774384807469896939244238162312381503538829297992”
“0563728311397730608512684802456729611629799237840717675459415085321717”
“3510045799893140980294678115716942993048524096036672853101036448636763”
“7521822128801546107878054289783619755055155704193064419917203870801606”
“1462706679770340215460640901795553063720621399977666861802490175519957”
“1181903932675738886345609841114940705582874540904040321503144262762124”
“6431970828135768845510402738705503521196770753208740086493376114491964”
“0560164090903204151684877637590541278783174713684696051854622495867752”
“7288231503190964916207260200695369240839782483693884561308799339634614”
“7865013989591759590985836386140030534223412375070695862703580788860085”
“3995922565271133375609856489334798627411200877205912880065914582091664”
“0321841134123848107954299712333327306249963417115143732933718469512611”
“6750287172714867070862217291618428046425851287410055539393868724853179”
“65460246701270779036186763104697237715741461”
};
char *expString =
“6596863909615908806200916870138046818894802762863255898405601546959637”
“5450988180628873135345460099908812334328153462706161351610677750405424”
“9926932779074839651752928724105882506615630455928445832857203684248147”
“4169300413806663159337389373520908494916237324837808544886091621717827”
“1958424578394982579489524465806095711773520252000131926729434126443764”
“1269668805549919990412848752368459015622524736134603651605210122950019”
“6922543208203662953912905889642708829040125944985729715718043623093622”
“5954591379999219308601204141311801207321264551671589231424665061804191”
“7002356771351308538842951982286851041552953776082892228094462648233518”
“7559759956501419131182053011677407005041465711254080027557843763422561”
“8783821633504293466737124026607751203776098891364300187258136822471024”
“7580703388142310638323377616961876007674737243155068924959175205095723”
“2056962710103111894866445260198436136039561532574397730888244175262621”
“7400101865199610188957799483650887285901323315055717856868588758158779”
“7621435009788442475766886288806451170641172092239582189865458477717175”
“9232264090065791519659207514698759036936041239810095287672129443962331”
“6508989573160637221448976975731710093109301619514186892888541990374804”
“6299371509286567297505394725706411159587707”;
char *baseString = “9767841436487994941683182014713021941210002638537939214963347443833888”;
ybn_t fromString(const char *str) {
ybn_t rv = ybn_alloc();
ybn_fromString(rv, str);
return rv;
}
void print(ybn_t ybn) {
static char *buf = NULL;
static int bufsize = 0;
int s = ybn_toString(ybn, buf, bufsize);
if (s > 0) {
buf = realloc(buf, s * 2);
bufsize = s * 2;
ybn_toString(ybn, buf, bufsize);
}
printf(“%s\n”, buf);
}
int main(int ac, char **av) {
int num = 5;
ybn_t base = fromString(baseString);
ybn_t exp = fromString(expString);
ybn_t mod = fromString(moduli[num]);
ybn_t res = ybn_alloc();
ybn_modexp(res, base, exp, mod);
print(res);
}