ChowlaFunction := n -> NumberTheory:-SumOfDivisors(n) - n - 1; PrintChowla := proc(n::posint) local i; printf("Integer : Chowla Number\n"); for i to n do printf("%d : %d\n", i, ChowlaFunction(i)); end do; end proc: countPrimes := n -> nops([ListTools[SearchAll](0, map(ChowlaFunction, [seq(1 .. n)]))]); findPerfect := proc(n::posint) local to_check, found, k; to_check := map(ChowlaFunction, [seq(1 .. n)]); found := []; for k to n do if to_check(k) = k - 1 then found := [found, k]; end if; end do; end proc: PrintChowla(37); countPrimes(100); countPrimes(1000); countPrimes(10000); countPrimes(100000); countPrimes(1000000); countPrimes(10000000); findPerfect(35000000)