Introduction
For the past two weeks, I attended the Wolfram High School Summer Camp and worked on a project about making integers from ones. In this project, I explored how many different integers can be made out of ones and various mathematical operations (addition, subtraction, exponent, and factorial). The purpose of this project was to find the fewest number of ones needed to reach each integer, and to explore all the different integers that can be calculated using different numbers of ones and different operations. I went up to using seven ones, and because of this some integers are unable to be reached. I made a chart that shows which integers can be made and how many ones it takes to make them.
Making a Chart Visual
Using the function Groupings
, I could group different numbers of ones in all the possible ways and with different operations.
intlist =
Map[Union,
Quiet[Select[#,
1000000000 > # > 0 && IntegerQ[#] &] & /@ (Groupings[
Table[1, #], {Plus -> 2, Subtract -> 2, Times -> 2,
Power -> 2, {Factorial -> 1, 1}}] & /@ Range[1, 7])]]
This outputs a list of lists of the integers under 1,000,000,000 that can be made with one through seven ones.
{{1}, {1, 2}, {1, 2, 3, 6}, {1, 2, 3, 4, 5, 6, 7, 24}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 23, 24, 25, 36, 64, 120, 720, 40320, 362880},
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 22, 23, 24, 25, 26, 27, 32, 35, 36, 37, 48, 49, 63, 64, 65, 119, 120,
121, 128, 216, 576, 719, 720, 721, 729, 5040, 40319, 40320, 40321, 362879, 362880, 362881, 3628800, 16777216},
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 36, 37,
38, 46, 47, 48, 49, 50, 62, 63, 64, 65, 66, 72, 81, 118, 119, 120, 121, 122, 125, 127, 128, 129, 144, 215, 216, 217, 240,
243, 256, 343, 512, 529, 575, 576, 577, 625, 718, 719, 720, 721, 722, 728, 729, 730, 1296, 1440, 2187, 4096, 5039,
5040, 5041, 13824, 14400, 40318, 40319, 40320, 40321, 40322, 80640, 362878, 362879, 362880, 362881, 362882,
518400, 725760, 3628799, 3628800, 3628801, 8388608, 16777215, 16777216, 16777217, 33554432, 39916800, 479001600}}
Using this list, I plotted the number of ones needed vs. the integer made:
pic = ListPlot[datapoints, PlotRange -> {{0, 100}, {0, 8}},
PlotMarkers -> {Automatic, 3}, AspectRatio -> 1/3, Filling -> Axis,
FillingStyle -> Darker[Blue],
AxesLabel -> {"Integer", "Number of Ones"}]
The y value is the number of ones needed to make the x value integer.
Making the Microsite Output Function
After creating the visual of how many ones are needed to get to certain integers, I made a function that outputs the most efficient way to make an inputted integer out of ones and the given operations. I started by making two lists: one list of the integers made and another list of the held form of the expression, showing how an integer was reached with ones and different operations.
Next, I threaded the lists together to make a list of associations that associates the integer with the expression of ones used to get the integer. Because of the included operations, such as subtraction and exponents, some expressions evaluated to a complex number, infinity, or zero. In addition, some numbers were extremely high because of the factorial operation. So, I only selected integers that are greater than zero and less than 1,000,000,000.
I then threaded the lists again to reverse the association and to get rid of duplicate integers. When making the original two lists, I reversed them so that when I threaded them together, the simpler expression with less ones would replace the more complicated expression with more ones.
After doing this, I was able to make a function that outputs the expression when the associated integer is inputted. In order to keep the format of the exponents and the other operations, I rasterized the output, making it a picture.
ClearAll[ones];
ones[number_Integer] := Replace[finalassoc[number], HoldComplete[stuff_] :> Rasterize[HoldForm[stuff]]]
The Microsite
Finally, I created my microsite, the final product of this project. When the user types in an integer, the expression of ones that makes that integer is outputted. I also added the chart that I made at the beginning as a visual.
CloudDeploy[
FormPage["Number" -> "Integer", ones[#Number] &,
AppearanceRules -> <|"Title" -> "Making Integers From Ones",
"Description" -> Column[{pic, "Enter an integer to see how you can make it from the least number of ones possible"}]|>,
PageTheme -> "Red"], Permissions -> "Public",
CloudObject["user:karina.ting18/onestest"]]
Here is a link to the microsite: https://www.wolframcloud.com/objects/karina.ting18/onestest
In order to expand and improve upon this project, more ones could be used so that more integers can be reached. From the chart visual, you can see that there are many gaps where seven ones and are not enough to make that integer. In addition, for very big integers, you could make a default output of simply adding together that many ones. Lastly, when smaller numbers are inputted, factorial signs are unnecessarily put next to a number one, which just equals one also. It would be ideal to get rid of this because it is unneeded and makes the expression less simple.
Even though I didn't get the chance to fix these problems, I loved exploring this project, and I learned so much over the past two weeks. I would like to thank my mentor Andrea Griffin and all the instructors at the Wolfram Summer High School Camp for all their help and guidance.
Attachments: