{
	a = vector(10 000);
	for (i=1, #a,
		my (f=i!);
		my (p=0);
		for (d=i, f,
			if (f % d==0,
				if (p,
					for (n=p+1, d-1,
						x = min(n-p, d-n);
						\\ d_k is i! periodic
						forstep (m=n, #a, f,
							a[m] += x;
						);
					);
					if (d >= #a,
						\\ no need to go beyond
						break;
					);
				);
				p = d;
			);
		);
		print (i " " a[i]);
	);
}

quit