python simple basic program on geeksforgeeks
<p>Can anyone help me with the solution of this ?</p>

<p>Given a number N, print all the composite numbers less than or equal to N. The number should be printed in ascending order.</p>

<p>Input:
The first line contain an Integer T denoting the number of  test cases . Then T test cases follow. Each test case consist of an single integer N.</p>

<p>Output:
Print all the composite Number form 0 to N.</p>

<p>Constraints:</p>

<pre><code>1 â¤ T â¤ 50
4 â¤ N â¤ 10000

Example:
Input:
2
10
6
Output:
4 6 8 9 10
4 6
</code></pre>

<p>My solution is as below :</p>

<pre><code>def comp(n):
    for i in range (4,n+1):
        for j in range(2,i):
            if i % j == 0 :
                print(i)
                break

t = int(input(""))

while(t &gt;=1 &amp; t &lt;= 50):
        for k in range(0,t):
            p = int(input(""))
            if(p &gt;=4 &amp; p &lt;= 10000):
                comp(p)
</code></pre>

<p>but giving <code>EOFError</code> on <code>p = int(input(""))</code></p>

<p>A simple solution using recursion.</p>

<pre><code>def check_prime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if(n%i==0):
            return 0
    return 1

def print_composite(n):
    if(n&lt;5):
        print(n),
        return
    print_composite(n-1)
    if(check_prime(n)==0):
        print(n),
        return
</code></pre>

<p>Sample outputs from my terminal</p>

<pre><code>&gt;&gt;&gt; print_composite(10)
4 6 8 9 10
&gt;&gt;&gt; print_composite(6)
4 6
&gt;&gt;&gt; print_composite(16)
4 6 8 9 10 12 14 15 16
</code></pre>

python