Help Needed: Finding the First 10 Apocalyptic Numbers

  • Thread starter Soff
  • Start date
  • Tags
    Numbers
In summary, the conversation discusses finding the first ten apocalyptic numbers, which are numbers of the form 2^n that contain the digits 666. The code provided to find these numbers uses Mathematica's Select and MatchQ functions, but it is incorrect due to not properly considering the structure of the numbers. The correct code is provided, which uses the Cases function and returns the results as integers.
  • #1
Soff
36
0
Hello!

I got a problem:

I want to find out the first ten apocalyptical numbers.By definition, a number of the form 2^n that contains the digits 666 (i.e., the beast number) is called an apocalyptic number.

I tried to write a short program with mathematica:

l := Table[2^n, {n, 1, 1000}]
a := IntegerDigits[l]
Select[a, MatchQ[a, {6, 6, 6}], 10]

However, the result is always {}
What's wrong with the program above?

Can somebody give me an advice?
 
Technology news on Phys.org
  • #2
First a general comment: in this case the use of SetDelayed := will cause reduced performance, because it is unnecessary to recalculate the table each time it is referred to.

Now, notice that the second argument of Select should be a function. If you execute:
Code:
MatchQ[a,{6,6,6}]

It returns False, because a (a table of list of digits of integers) does not literally match {6,6,6}. What we really want is a function that compares each element of a with {6,6,6}, which could be given as:
Code:
l := Table[2^n, {n, 1, 1000}]
a := IntegerDigits[l]
Select[a, MatchQ[#, {6, 6, 6}]&, 10]

(the # is the formal parameter of the pure function and the & delimits its body).

Now executing the code I gave still returns the empty set, and this is because we are only checking for numbers that match 666, not those of the form:

*digits* 666 *more digits*

To do this in mathematica we use a BlankSequence (two underscores). This works to find your numbers:
Code:
l = Table[2^n, {n, 1, 1000}];
a = IntegerDigits[l];
Select[a, MatchQ[#, {__,6, 6, 6,__}]&, 10]

but since we are matching a pattern rather then testing a boolean, it makes more sense to use Cases:

l = Table[2^n, {n, 1, 1000}];
a = IntegerDigits[l];
Take[Cases[a, {__,6, 6, 6,__}], 10]
It might be nice to return the results as integers, rather then lists, and write the program in one line:

Code:
FromDigits/@Take[Cases[IntegerDigits@Table[2^n,{n,1,2000}],{__,6,6,6,__}],10]
 
Last edited:
  • #3


Hi there! I can definitely help you with finding the first 10 apocalyptic numbers. First of all, the program you wrote is close, but there are a few things that need to be fixed. Here are some tips:

1. Instead of using the variable "l" to store the list of powers of 2, you can directly use the Table function in your Select statement. So your code will look like this:

Select[Table[2^n, {n, 1, 1000}], MatchQ[IntegerDigits[#], {6, 6, 6}] &, 10]

2. The issue with your code is that you are using the MatchQ function incorrectly. The first argument of MatchQ should be the pattern you are looking for, and the second argument should be the expression you want to match. So in this case, the pattern should be {6, 6, 6} and the expression is the list of digits in each number. Therefore, the correct code is:

Select[Table[2^n, {n, 1, 1000}], MatchQ[{6, 6, 6}, IntegerDigits[#]] &, 10]

3. Lastly, the reason why you are getting an empty list as a result is because there are no numbers between 2^1 and 2^1000 that contain the digits {6, 6, 6}. In fact, the first apocalyptic number is 2^6 = 64. So if you change the range in your Table statement to {n, 1, 10}, you will get the first 10 apocalyptic numbers.

I hope this helps! Let me know if you have any further questions. Good luck with your search!
 

FAQ: Help Needed: Finding the First 10 Apocalyptic Numbers

What are apocalyptic numbers?

Apocalyptic numbers are numbers that contain the sequence "666" in their digits. They are also known as "beastly numbers" or "evil numbers".

Why is it important to find the first 10 apocalyptic numbers?

Finding the first 10 apocalyptic numbers is important because it is a mathematical curiosity and can help us understand patterns in numbers. It can also have cultural and religious significance for some people.

How do you find apocalyptic numbers?

To find apocalyptic numbers, you need to search for the sequence "666" within the digits of numbers. This can be done manually or with the help of a computer algorithm.

What are some examples of apocalyptic numbers?

Some examples of apocalyptic numbers are 1666, 2666, 3666, 4666, 5666, 6660, 6661, 6662, 6663, and 6664. These are the first 10 apocalyptic numbers in ascending order.

Are apocalyptic numbers considered to be unlucky or evil?

The concept of apocalyptic numbers being unlucky or evil is subjective and varies from person to person. Some may see them as just a mathematical curiosity, while others may attach religious or superstitious beliefs to them.

Back
Top