c - Searching number without reminder -


what main problem in algorithm,i need find smallest positive number divided 1 20 out divider...

#include <stdio.h> #include <stdbool.h>  int main(int argc,char* argv[]) { int num,j=2; int savenum=20; bool flag = false; while(!flag) {     num = savenum;     while(num%j==0 && j<=20)     {         num /= j;         j++;     }     if(j>20)         flag = true;     else     {      savenum++;      j=1;     } } printf("done"); printf("%d",savenum); } 

are missing printf see intermediate results are? might idea going on internally.

but don't understand you're trying solve. want result: 2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20?

because think that's computing. however, you'll overflow before there , iterating point take while.

if instead you're trying find smallest number divisible every number less or equal 20, may want revisit update of num /= j.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -