Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ignacio Alejandro Ruiz Garrido
- //14 de Agosto
- //Números Interesantes
- //Buscar dentro de un rango de números, el mayor número interesante
- #include<stdio.h>
- int main ()
- {
- unsigned short limInf;
- unsigned short limSup;
- unsigned short Suma;
- unsigned short CantDiv;
- unsigned short Num;
- unsigned short aux;
- unsigned short Interesante=0;
- unsigned short MaxDiv=0;
- unsigned short MaxSuma=0;
- unsigned short flag=0;
- scanf("%hu %hiu",&limInf,&limSup);
- printf ("%hu limsup %hu",&limInf,&limSup);
- for (Num=limInf;Num<=limSup;Num++)
- {
- Suma=0;
- CantDiv=0;
- for (aux=1;aux<=(Num/2);aux++)
- {
- if ((Num%aux)==0)
- {
- CantDiv++;
- Suma=Suma+aux;
- }
- }
- if (Suma>Num)
- {
- flag=1;
- if (CantDiv>MaxDiv)
- {
- MaxSuma=Suma;
- MaxDiv=CantDiv;
- Interesante=Num;
- }
- }
- }
- if (flag)
- {
- printf("Entre %hu y %hu, el numero %hu tiene %hu divisores y la suma de sus divisores es %hu",&limInf,&limSup,&Interesante,&MaxDiv,&MaxSuma);
- }
- else
- {
- printf ("No se encontro numero que cumpliera las condiciones!");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement