Find factors of a number
You should realize that if \$i\$ is a divisor of \$a\$, then so is \$a / i\$. This way you get two divisors per found divisor.

In the same vein, you only need to search up to \$\sqrt{n}\$, because all factors above that have already been found as the second divisor.

So your code would become:

#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main(){
        int a,i;
        scanf("%d",&amp;a);
        int bound = ceil(sqrt(a));
        for(i=1; i &lt;= bound; i++) {
                if(a%i==0) {
                        printf("%d\n",i);
                        if(a/i != i) printf("%d\n", a/i);
                }
        }
        printf("%d\n",a);
        return 0;
}