Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int prueba(int x);
  4.  
  5. main()
  6. {
  7.         long int p=0,n=20;
  8.         while(p!=1)
  9.         {
  10.                 n=n+20;//como debe ser divisible por 20,pruebo sólo múltiplos de 20
  11.                 p=prueba(n);
  12.         }
  13.         printf("El menor divisible por los nros 1 al 20 es %d\n",n);
  14. }
  15.  
  16. int prueba(int x)//verifico q sea divisible por el todos los nros del rango
  17. {
  18.         int i;
  19.         for(i=19;i>1;i--)//no verifico para 20 o 1 porq ya se q es divisible por ambos
  20.         {
  21.                 if(x%i!=0)
  22.                 {
  23.                         return(0);
  24.                 }
  25.         }
  26.         return(1);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement