From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-29-2015 05:08 PM
I'm new to LabVIEW and am having difficulty with one of the problems from CH.2 of hands on introduction to LabVIEW. The problem states:
The odd integers are given by 2i + 1, where i = 0, 1, 2 ... Write a program that answers the following question: What is the smallest odd integer that is divisible by 3 and also, when cubed, yields a value greater than 4000? Display the answer to this question in a front pannel Numeric Indicator.
I have my front and block diagram attached. I believe I have the beginning and end parts of the code correct, I'm confused how to tackle the part where it must be odd and divisible by 3. Any ideas? Thank you.
Solved! Go to Solution.
06-29-2015 05:21 PM - edited 06-29-2015 05:26 PM
An odd interger that is divisible by 3 is an odd multiple of 3, so replace your Q&R with a multiplication by 3, then test cube value of it. See how far you get.
Also make sure to wire the numeric indicator to the value going into the cubing, the value of [i] is not iteresting.
06-30-2015 09:43 AM
Thank you that helped. There was suggested icons such as the Q&R, Power of X, and And. I'm still not sure how to incorporate the Q&R and And, but I'm sure i'll figure it out soon
06-30-2015 09:54 AM
@dagabeo7 wrote:
Thank you that helped. There was suggested icons such as the Q&R, Power of X, and And. I'm still not sure how to incorporate the Q&R and And, but I'm sure i'll figure it out soon
Well, the use of Q&R would complicate the code and it simply leads to another algorithm. Do you really have to use it?
What you would do instead is inspect [i] directly (less effiicient, because there will be many more to inspect. No big deal for a computer, though!). At each iteration, divide [i] by 3 using Q&R and see if the remainder is zero. if it is, [i] is divisble by three. Now see if the number is odd (you know how to do that, right?), and if both are true do the cubeing and check the size of the result. etc.
You could also do a hybrid approach, multiplying [i] by 3 at each iteration and then checking if the result is odd by using Q&R (dividing by 2) and see if the R is nonzero., etc.
As an exercise, You should do all three approaches and see if you get the same result. Also see which one uses the fewest number of iterations to find the solution.
06-30-2015 10:07 AM
Hi,
What is the smallest odd integer that is divisible by 3 and also, when cubed, yields a value greater than 4000?
x = 3*n x^3 > 4000 -> x > 4000^(1/3) -> x > 15.9 multiples of 3 greater than 15.9: 18, 21, 24, …
You really need a tool to provide the answer? 😄
06-30-2015 10:27 AM - edited 06-30-2015 10:29 AM
GerdW wrote:x = 3*n x^3 > 4000 -> x > 4000^(1/3) -> x > 15.9 multiples of 3 greater than 15.9: 18, 21, 24, …
What's that gibberish? I thought this is the LabVIEW forum! 😄
-> x > 15.9
... so the minus sign is greater than x which is greater than 15.9? No wonder I am a graphical programmer. 😮
I don't think this is an exercise in number theory, but an exercise in LabVIEW programming (while loop, some math, condition checking, loop termination). You also left out a step, because you still need to check which result is odd. 😉
(Just being silly of course....)
07-01-2015 10:24 AM
It was just an exercise problem. I don't think the problem is necessarily asking for the best approach, rather its just asking to attack the problem using these icons. Thank you for the help though. The correct answer is 21, I augmented the code and got it to spit out 21.
07-01-2015 10:35 AM - edited 07-01-2015 01:10 PM
@dagabeo7 wrote:
It was just an exercise problem. I don't think the problem is necessarily asking for the best approach, rather its just asking to attack the problem using these icons. Thank you for the help though. The correct answer is 21, I augmented the code and got it to spit out 21.
Well, the original problem description in your first post makes no restrictions on the tools to be used. If the puzzle asks to solve the problem given exactly the tools on your original diagram, nothing more, nothing less, that's a different problem (and I don't think it is solvable!) and you should have mentioned it in your first post. 😄
Feel free to show us your code for comments and suggestions
07-23-2015 08:47 PM - edited 07-23-2015 08:49 PM
it's too obvious "INTEGER"
not a floating point precision with decimal places
and clearly said it is an "ODD INTEGER"
an ODD and an INTEGER
😛
07-23-2015 11:13 PM
@dhumpsy wrote:
an ODD and an INTEGER
Are you replying to any particular post or statement?