Preview

Bit-Sum Prime

Satisfactory Essays
Open Document
Open Document
284 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Bit-Sum Prime
Gems

from

the

world

of

data

structures

and

algorithms

Bit-Sum Prime
Difficulty level: moderate

Every student, who has learned programming, must have written a program to determine whether a given positive integer is a prime number. Basically in order to determine whether a positive integer n is prime, we search for any number in the range [2, n − 1] which can divide n. Some of you would have designed a slighly better implementation where you search √ for any divisor of n from the range [2, n ]. Does either of these two implementations correspond to an efficient algorithm ? Ponder over this question deeply. Let us try to design an efficient algorithm for a problem which looks as simple and innocent as the problem discussed above. First, we give a definition. Definition 1. A positive integer is said to be bit-sum prime if the sum of the bits in its binary representation is a prime number. For example 6(110), 14(1110) are bit-sum prime numbers, whereas 29(11101) is not a bit-sum prime number. Design and implement an algorithm which receives a 64-bit integer n and outputs the count of all the bit-sum prime numbers less than n. Test it for a really large number, for example, execute your algorithm for 123456789123456789. Hint: Your algorithm/program is NOT supposed to enumerate all the bit-sum prime numbers. Instead, it has to just report the count of all the bit-sum prime number. Hence the output will be just a single number. Notice that you will have to use clever programming skills also in this problem.

every art is beautiful and so is the art of algorithm design ...

1

You May Also Find These Documents Helpful

  • Good Essays

    Pow #1- a Digital Proof

    • 678 Words
    • 3 Pages

    The problem in A Digital Proof has two parts. The first is to fill in five boxes with numbers that fit the criteria: each box has a number, and the digit that is placed in each box must be the amount of times that number appears in the whole five digit number formed by the boxes. The second part of the problem is to prove that there is only one solution.…

    • 678 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Nt1310 Unit 1 Exercise 1

    • 5033 Words
    • 21 Pages

    Figure: Euclidean division algorithm The message is represented by a information polynomial i(x). i(x) is store as a bit pattern of k length in an integer array. The k information bits are represented by k-1 degree polynomial i(x) = i(k-1)x(k-1) + i(k-2)x(k-2) +……………………………..+i1x+i0 A polynomial code is specified by its generating polynomial g(x). If we assume that we are dealing with a code in which codewords have n bits of which k are information bits and n-k are check bits . The…

    • 5033 Words
    • 21 Pages
    Powerful Essays
  • Satisfactory Essays

    Say the prime numbers in this series: 2, 3, 4, 5, 6. 2, 3, 5…

    • 2120 Words
    • 9 Pages
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 3 Lab Report

    • 880 Words
    • 4 Pages

    For most of the questions I found the divisors or made generalizations based on other information I gained via other numbers divisors or I used logic to figure out simple rules to apply to the numbers.…

    • 880 Words
    • 4 Pages
    Good Essays
  • Better Essays

    Pow Write-Up 1

    • 1175 Words
    • 5 Pages

    When I first saw the POW, I thought that finding the solution would be fairly easy, by just plugging different numbers into the boxes and play around with them. I soon discovered that that wasn’t the case. So using deductive reasoning, I began off by acknowledging that there couldn’t be any number over four in the boxes, because if it was above four, it wouldn’t be the right solution. If I put a five in any box, I knew that there would only be four boxes left, which wouldn’t work. So I ruled out any number over four.…

    • 1175 Words
    • 5 Pages
    Better Essays
  • Satisfactory Essays

    Number Conversions

    • 180 Words
    • 2 Pages

    2.Convert your binary result back into decimal to prove your answer is correct. This is also…

    • 180 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    In my mind I made a number line and crossed off every even number, then the odds divisible by three, five, seven and nine (except themselves), and, of course, one. Looking for twin primes, I located 17 and 19, 11 and 13, as well the triplet three, five and seven, which I divided into two twin primes.…

    • 537 Words
    • 3 Pages
    Good Essays
  • Good Essays

    it320 assignment 1-3

    • 1779 Words
    • 8 Pages

    7. A user has opened a calculator application, typed the numbers 123456789, and then done some math problem using this number. Which of the following determines, in part, what bits the computer (D. the binary equivalent of decimal 123456789)…

    • 1779 Words
    • 8 Pages
    Good Essays
  • Good Essays

    Using the formula X^2 –X + 41 to try if we can get a prime number was fun and interesting. I chose to use the numbers 0, 5,8,10, and 13, that is two even numbers and two…

    • 635 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Partial Sums of Primes

    • 4599 Words
    • 19 Pages

    Where n ranges over the positive integers from 1 to infinity and where s is a complex number. To get an understanding of the importance of this function, one needs to know some history about it. Dating back to the times of Euclid, the prime numbers have been studied in great deal. What makes them the most interesting over the other numbers is that they hold a special property of not being able to be decomposed into to separate integers. The only numbers that the primes are divisible by is one and themselves. Another, more interesting topic about the primes is their distribution. The question that is asked is “Are the primes distributed in a regular pattern or just randomly placed throughout the integers?” This question is answered by the Riemann Hypothesis to an extent.…

    • 4599 Words
    • 19 Pages
    Good Essays
  • Good Essays

    Rational Numbers

    • 311 Words
    • 2 Pages

    A rational number is a number that can be written as a ratio of two integers. The decimal of a rational number will either repeat or terminate. There is a way to tell in advance whether a rational number’s decimal representation will repeat or terminate. When trying to find a pattern in the relationship between rational numbers and their decimals, it is best to start with a list. A random list of rational numbers and their decimal values was made in order to find a pattern. The list included ½, 5/6, 44/10, 3/7, 23/36, 89/53, 3/50, and 4/31. These ratios were 0.5, 0.8333…, 4.4, 0.42857…, 0.63888…, 1.67924…, 0.06, and 0.12903… in decimal form. When analyzing these rational numbers, they were placed into categories of repeating and terminating decimals. In the terminating decimal category, the numbers ½, 44/10, and 3/50 had something in common. It was determined that each of the denominators were multiples of two. To solidly identify a pattern, more examples were used. Rational numbers such as 2/25, 6/8, and 9/64 helped to identify a definite pattern. What all the denominators of terminating decimals shared was the fact that their prime factors included only 2’s and 5’s. When 2, 10, 50, 25, 8, and 64 were prime factorized the only prime factors were 2’s and 5’s. When the denominators of the repeating decimals were prime factorized, there were other prime numbers although some 2’s and 5’s were still included. These observations helped lead to the conclusion that there is a way to tell in advance whether a rational number’s decimal representation will be repeating or terminating. If the denominator’s prime factors are only 2’s and 5’s, then the decimal will terminate. If not, it will be a repeating…

    • 311 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Consider the following formula _ and its two interpretations I1 and I2 ]] 〈: (x)[Px  (y)[Qxy  ¬Qyy (x)[¬Px] I1: Domain: the set of natural numbers Px α ”x is a prime number‘ Qxy α ”y divides x‘ I2: same as I1 except that Px = ”x is a composite number‘. Which of the following statements is true? (A) I1 satisfies 〈, I2 does not (C) Neither I2 nor I1 satisfies 〈 (B) I2 satisfies 〈, I1 does not (D) Both I1 and 12 satisfy 〈…

    • 5183 Words
    • 21 Pages
    Good Essays
  • Satisfactory Essays

    Find the LCM and HCF of 26 and 91 and verify that LCM × HCF = product of the two numbers.…

    • 829 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    So, what is the Goldbach’s Conjecture? Goldbach’s Conjecture states that “Every number greater than 2 can be written as the sum of two primes”. It is an unsolved problem and when the book “Uncle Petros and the Goldbach’s Conjecture” was released, Tony Faber (British publisher) decided to offer one million dollars for the proof of the conjecture. Proofs were only accepted before April 2002 but none of the proofs were right so of course, the money went nowhere except in Faber’s pocket. Though, a lot of mathematicians got intermediate results from researching and investigating the Goldbach’s Conjecture.…

    • 815 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Keep this chart in a place you look at every day so that you can track your savings progress…

    • 257 Words
    • 10 Pages
    Satisfactory Essays