Determining the values for an array within limits
So I did some math on a function to produce positions within an array of which I wanted to record data. My initial math looked like this:
$$ (n * frac{100}{n})-1$$
This would allow me to determine the upper limit of the array, and then I could capture the data in each position of that multiple...
ex if $n = 7$:
The first array set of values would be 0, 7, 14, 21...98
The second array 1, 8, 15, 22...99
The third 2, 9, 16, 23...93
What I was trying to do was determine the max multiple of $n$ in 0-99. This worked for the values that we were initially given. $n$ could have been 7 or 8. Now, the customer has requested that the value range be 5 to 8. This produced a signifigant problem because the result of the above formula became 100 when $n$ was 5. The array upper bounds is 99, so we can't use the value of 100. How can I change the formula so that it can be an all in one solution and we don't have to worry about limits? Basically, the value produced should be the greatest multiple of $n$ that is 99 or less, minus 1.
Ex:
$n=8$ should produce a value of 95 $8*12-1$
$n=7$ should produce a value of 97 $7*14-1$
$n=6$ should produce a value of 95 $6*16-1$
$n=5$ should produce a value of 99 $5*20-1$
$n=4$ should produce a value of 95 $4*24-1$
recreational-mathematics
add a comment |
So I did some math on a function to produce positions within an array of which I wanted to record data. My initial math looked like this:
$$ (n * frac{100}{n})-1$$
This would allow me to determine the upper limit of the array, and then I could capture the data in each position of that multiple...
ex if $n = 7$:
The first array set of values would be 0, 7, 14, 21...98
The second array 1, 8, 15, 22...99
The third 2, 9, 16, 23...93
What I was trying to do was determine the max multiple of $n$ in 0-99. This worked for the values that we were initially given. $n$ could have been 7 or 8. Now, the customer has requested that the value range be 5 to 8. This produced a signifigant problem because the result of the above formula became 100 when $n$ was 5. The array upper bounds is 99, so we can't use the value of 100. How can I change the formula so that it can be an all in one solution and we don't have to worry about limits? Basically, the value produced should be the greatest multiple of $n$ that is 99 or less, minus 1.
Ex:
$n=8$ should produce a value of 95 $8*12-1$
$n=7$ should produce a value of 97 $7*14-1$
$n=6$ should produce a value of 95 $6*16-1$
$n=5$ should produce a value of 99 $5*20-1$
$n=4$ should produce a value of 95 $4*24-1$
recreational-mathematics
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30
add a comment |
So I did some math on a function to produce positions within an array of which I wanted to record data. My initial math looked like this:
$$ (n * frac{100}{n})-1$$
This would allow me to determine the upper limit of the array, and then I could capture the data in each position of that multiple...
ex if $n = 7$:
The first array set of values would be 0, 7, 14, 21...98
The second array 1, 8, 15, 22...99
The third 2, 9, 16, 23...93
What I was trying to do was determine the max multiple of $n$ in 0-99. This worked for the values that we were initially given. $n$ could have been 7 or 8. Now, the customer has requested that the value range be 5 to 8. This produced a signifigant problem because the result of the above formula became 100 when $n$ was 5. The array upper bounds is 99, so we can't use the value of 100. How can I change the formula so that it can be an all in one solution and we don't have to worry about limits? Basically, the value produced should be the greatest multiple of $n$ that is 99 or less, minus 1.
Ex:
$n=8$ should produce a value of 95 $8*12-1$
$n=7$ should produce a value of 97 $7*14-1$
$n=6$ should produce a value of 95 $6*16-1$
$n=5$ should produce a value of 99 $5*20-1$
$n=4$ should produce a value of 95 $4*24-1$
recreational-mathematics
So I did some math on a function to produce positions within an array of which I wanted to record data. My initial math looked like this:
$$ (n * frac{100}{n})-1$$
This would allow me to determine the upper limit of the array, and then I could capture the data in each position of that multiple...
ex if $n = 7$:
The first array set of values would be 0, 7, 14, 21...98
The second array 1, 8, 15, 22...99
The third 2, 9, 16, 23...93
What I was trying to do was determine the max multiple of $n$ in 0-99. This worked for the values that we were initially given. $n$ could have been 7 or 8. Now, the customer has requested that the value range be 5 to 8. This produced a signifigant problem because the result of the above formula became 100 when $n$ was 5. The array upper bounds is 99, so we can't use the value of 100. How can I change the formula so that it can be an all in one solution and we don't have to worry about limits? Basically, the value produced should be the greatest multiple of $n$ that is 99 or less, minus 1.
Ex:
$n=8$ should produce a value of 95 $8*12-1$
$n=7$ should produce a value of 97 $7*14-1$
$n=6$ should produce a value of 95 $6*16-1$
$n=5$ should produce a value of 99 $5*20-1$
$n=4$ should produce a value of 95 $4*24-1$
recreational-mathematics
recreational-mathematics
edited Dec 8 at 10:48
asked Dec 8 at 10:18
Jaberwocky
1055
1055
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30
add a comment |
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30
add a comment |
1 Answer
1
active
oldest
votes
The maximum multiple of a number in $0-99$ is given by $Big[frac{99}{n}Big]times n$ (where [.] is the greatest integer function).
Hope it is helpful:)
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030920%2fdetermining-the-values-for-an-array-within-limits%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The maximum multiple of a number in $0-99$ is given by $Big[frac{99}{n}Big]times n$ (where [.] is the greatest integer function).
Hope it is helpful:)
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
add a comment |
The maximum multiple of a number in $0-99$ is given by $Big[frac{99}{n}Big]times n$ (where [.] is the greatest integer function).
Hope it is helpful:)
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
add a comment |
The maximum multiple of a number in $0-99$ is given by $Big[frac{99}{n}Big]times n$ (where [.] is the greatest integer function).
Hope it is helpful:)
The maximum multiple of a number in $0-99$ is given by $Big[frac{99}{n}Big]times n$ (where [.] is the greatest integer function).
Hope it is helpful:)
answered Dec 8 at 10:31
Martund
1,351212
1,351212
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
add a comment |
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
So basically you're telling me if I didn't over complicate the firsts formula, I wouldn't be having this problem? :P
– Jaberwocky
Dec 8 at 10:35
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
Uhg, you're right. Don't know how I missed that. Thanks!
– Jaberwocky
Dec 8 at 10:43
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030920%2fdetermining-the-values-for-an-array-within-limits%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please recheck your calculations: 95 = 8*12-1 and 95 = 6*16-1.
– Martund
Dec 8 at 10:24
@Crazyformaths done, thanks.
– Jaberwocky
Dec 8 at 10:30