int FiatShamir::MCD(int x, int y) //maximo comun divisor para saber si s es primo con n, el mcd tiene que ser 1 { if(y==0) return x; else return MCD(y, x%y); }
int MCD(int x, int y){ if(x%y==0) return y; else{ return MCD(y,x%y); } }
void main(){ int a,b,m; printf("introduzca dos numeros enteros a y b (a>b): \n"); scanf("%d%d",&a,&b); m=MCD(a,b); printf("el MCD(%d,%d)=%d\n",a,b,m); }
/* that means when I load stddef.h it only defines size_t and doesn't */ /* do offset_of, which is what I need */ # undef __need_size_t #endif #include <stddef.h> #ifdef FONTFORGE_CONFIG_DEVICETABLES #define MCD(ui_name,name,msg,np) { ui_name, #name, offsetof(struct MATH,name), -1,msg,np } #define MCDD(ui_name,name,devtab_name,msg,np) { ui_name, #name, offsetof(struct MATH,name), offsetof(struct MATH,devtab_name),msg,np } #else #define MCD(ui_name,name,msg,np) { ui_name, #name, offsetof(struct MATH,name), -1,msg,np } #define MCDD(ui_name,name,devtab_name,msg,np) { ui_name, #name, offsetof(struct MATH,name), -2,msg,np } #endif struct math_constants_descriptor math_constants_descriptor[] = { MCD(N_("ScriptPercentScaleDown:"),ScriptPercentScaleDown,N_("Percentage scale down for script level 1"),0), MCD(N_("ScriptScriptPercentScaleDown:"),ScriptScriptPercentScaleDown,N_("Percentage scale down for script level 2"),0), MCD(N_("DelimitedSubFormulaMinHeight:"),DelimitedSubFormulaMinHeight,N_("Minimum height at which to treat a delimited\nexpression as a subformula"),0), MCD(N_("DisplayOperatorMinHeight:"),DisplayOperatorMinHeight,N_("Minimum height of n-ary operators (integration, summation, etc.)"),0), MCDD(N_("MathLeading:"),MathLeading,MathLeading_adjust,N_("White space to be left between math formulae\nto ensure proper line spacing."),0), MCDD(N_("AxisHeight:"),AxisHeight,AxisHeight_adjust,N_("Axis height of the font"),0), MCDD(N_("AccentBaseHeight:"),AccentBaseHeight,AccentBaseHeight_adjust,N_("Maximum (ink) height of accent base that\ndoes not require raising the accents."),0), MCDD(N_("FlattenedAccentBaseHeight:"),FlattenedAccentBaseHeight,FlattenedAccentBaseHeight_adjust,N_("Maximum (ink) height of accent base that\ndoes not require flattening the accents."),0), MCDD(N_("SubscriptShiftDown:"),SubscriptShiftDown,SubscriptShiftDown_adjust,N_("The standard shift down applied to subscript elements.\nPositive for moving downward."),1), MCDD(N_("SubscriptTopMax:"),SubscriptTopMax,SubscriptTopMax_adjust,N_("Maximum height of the (ink) top of subscripts\nthat does not require moving\nubscripts further down."),0), MCDD(N_("SubscriptBaselineDropMin:"),SubscriptBaselineDropMin,SubscriptBaselineDropMin_adjust,N_("Maximum allowed drop of the baseline of\nsubscripts realtive to the bottom of the base.\nUsed for bases that are treated as a box\nor extended shape. Positive for subscript\nbaseline dropped below base bottom."),0), MCDD(N_("SuperscriptShiftUp:"),SuperscriptShiftUp,SuperscriptShiftUp_adjust,N_("Standard shift up applied to superscript elements."),0), MCDD(N_("SuperscriptShiftUpCramped:"),SuperscriptShiftUpCramped,SuperscriptShiftUpCramped_adjust,N_("Standard shift of superscript relative\nto base in cramped mode."),0), MCDD(N_("SuperscriptBottomMin:"),SuperscriptBottomMin,SuperscriptBottomMin_adjust,N_("Minimum allowed hieght of the bottom\nof superscripts that does not require moving\nthem further up."),0), MCDD(N_("SuperscriptBaselineDropMax:"),SuperscriptBaselineDropMax,SuperscriptBaselineDropMax_adjust,N_("Maximum allowed drop of the baseline of\nsuperscripts realtive to the top of the base.\nUsed for bases that are treated as a box\nor extended shape. Positive for superscript\nbaseline below base top."),0), MCDD(N_("SubSuperscriptGapMin:"),SubSuperscriptGapMin,SubSuperscriptGapMin_adjust,N_("Minimum gap between the supersecript and subscript ink."),0),
int FiatShamir::comprobarDatos() //comprobamos que p,q sean numeros primos y s es primo con N //comprobamos que 0<x<N 0<s<N { if(isPrimo( p.toInt())==1 && isPrimo(q.toInt())==1 ){ qDebug()<<"p y q son primos"; if(ui->xw->text().toInt() > 0 && ui->xw->text().toInt() < n && s.toInt() > 0 && s.toInt() < n && MCD(s.toInt(),n)==1){ qDebug()<<"Se cumple: 0<x<n\t0<s<n\ts es primo con n"; return 1; //cumple con los requisitos } } return 0; //no cumple con los requisitos }
fraccion Simplificar(fraccion f) { int mcd = MCD(f.num,f.den); f.num /= mcd; f.den /= mcd; return f; }