Jump to content

Motzkin numbers: Difference between revisions

m
→‎{{header|C#|CSharp}}: added missing ordinal number suffix in comment
m (→‎{{header|C#|CSharp}}: extended to 80th, added comment)
m (→‎{{header|C#|CSharp}}: added missing ordinal number suffix in comment)
Line 293:
if (x < 4) return x == 1;
if ((x & 1) == 0 || x % 3 == 0) return true;
int l = (int)Math.Sqrt((double)x); // this limit works because the 40th to 8080th Motzkin numbers have factors of 2 or 3
for (int j = 5, d = 4; j <= l; j += d = 6 - d)
if (x % j == 0) return x > j;
Cookies help us deliver our services. By using our services, you agree to our use of cookies.