Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int prueba(int x);
- main()
- {
- long int p=0,n=20;
- while(p!=1)
- {
- n=n+20;//como debe ser divisible por 20,pruebo sólo múltiplos de 20
- p=prueba(n);
- }
- printf("El menor divisible por los nros 1 al 20 es %d\n",n);
- }
- int prueba(int x)//verifico q sea divisible por el todos los nros del rango
- {
- int i;
- for(i=19;i>1;i--)//no verifico para 20 o 1 porq ya se q es divisible por ambos
- {
- if(x%i!=0)
- {
- return(0);
- }
- }
- return(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement