#include <iostream>
#include <cstdio>
#include <map>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
int main(){
  ll n;
  while(cin >> n,n){
    vector<ll>ve;
    map<ll,ll>mp,ans;
    for(int i = 1 ; i*2 < n ; i++ ){
      if(mp[(i*i)%n] == 0)ve.push_back((i*i)%n);
      mp[(i*i)%n] = 1;
    }
    sort(ve.begin(),ve.end());
    vector<ll>::iterator a =  ve.begin(),b;
    for(; a != ve.end() ; a++ ){
      for(b = a; b != ve.end() ; b++ ){
	if(*b == *a)continue;
	if(((*b) - (*a)) > (n-1)/2 ){
	  ans[(n - (*b) + (*a))]+=2;
	} else {
	  ans[(*b) - (*a)]+=2;
	}
      }
    }
    map<ll,ll>::iterator it =  ans.begin();
    for(; it != ans.end() ; it++)if((*it).first != 0)cout << (*it).second << endl;
  }
  return 0;
}