Timer is Running

Associated Course(s):
Geeks Classes
Geeks Classes DSA- Tutorials

Given a positive integer N, the task is to find the number of different ways in which **N **can be written as a sum of two or more positive integers.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integer **N**.

**Output:**

For each testcase, in a new line, output the number of ways **N **can be written as the sum of two or more positive integers for each test case in a new line. Since the answer can be quite large **print the answer modulo 10 ^{9}+7**.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{3}

**Example:**

**Input:**

2

5

3

**Output:**

6

2

**Explanation:
Testcase1:**

5:

1+1+1+1+1

1+1+1+2

1+1+3

1+4

2+1+2

2+3

So, a total of 6 ways.

Author: sujnesh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

visutkarsh2000 | 251 |

ayushaggarwal821 | 248 |

ashishboss9977 | 236 |

tekuripurushotham | 178 |

ramharshrai1999 | 151 |

abnandi04 | 776 |

KshamaGupta | 499 |

ponnadasaikesav | 450 |

ayushaggarwal821 | 415 |

yogesh_aka_dante | 405 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4752 |

Login to report an issue on this page.