Talk:Pernicious numbers: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 2: Line 2:
Hi, the C solution is a bit mysterious to me. The for loop seems to "remove the zeros" if I understand correctly, but then what's so special about 2693408940 ?? How can a simple bitwise & tell if the number of 1 (which is now the length since all zeros have been removed) is prime?
Hi, the C solution is a bit mysterious to me. The for loop seems to "remove the zeros" if I understand correctly, but then what's so special about 2693408940 ?? How can a simple bitwise & tell if the number of 1 (which is now the length since all zeros have been removed) is prime?
A bit of explanation in the introduction of the section or in comment would be welcome--[[User:Grondilu|Grondilu]] ([[User talk:Grondilu|talk]]) 14:43, 12 March 2014 (UTC)
A bit of explanation in the introduction of the section or in comment would be welcome--[[User:Grondilu|Grondilu]] ([[User talk:Grondilu|talk]]) 14:43, 12 March 2014 (UTC)
:Edit, hum after some thinking it appears that 2693408940 encodes the prime numbers in its binary form: 10100000100010100010100010101100. From right to left, starting from 0, the one marks the primes. Sill this could use some explanations.--[[User:Grondilu|Grondilu]] ([[User talk:Grondilu|talk]]) 14:51, 12 March 2014 (UTC)

Revision as of 14:51, 12 March 2014

C solution too cryptic?

Hi, the C solution is a bit mysterious to me. The for loop seems to "remove the zeros" if I understand correctly, but then what's so special about 2693408940 ?? How can a simple bitwise & tell if the number of 1 (which is now the length since all zeros have been removed) is prime? A bit of explanation in the introduction of the section or in comment would be welcome--Grondilu (talk) 14:43, 12 March 2014 (UTC)

Edit, hum after some thinking it appears that 2693408940 encodes the prime numbers in its binary form: 10100000100010100010100010101100. From right to left, starting from 0, the one marks the primes. Sill this could use some explanations.--Grondilu (talk) 14:51, 12 March 2014 (UTC)