1. ## A Problem

The Problem:

The cubes of all integers can be expressed as sums of adjacent odd integers. For example:
2*2*2=8 =3+5
3 * 3 * 3 = 27 = 7 + 9 + II
4 * 4 * 4 = 64 = I + 3 + 5 + 7 + 9 + II + 13 + 15
5 * 5 * 5 = 125 =21 +23 +25 +27 +29

Write a program to read in a number (for example: 5) and write out the number cubed (125) expressed as a sum of adjacent odd inte3ers (21 + 23 + 25 + 27 + 29). Your program should find the lowest adjacent integer odd sum. For example, 4 = 64 also has an adjacent odd sum of 13 + 15 + 17 + 19. Your program should find the odd sum for 43 shown above that starts at I. This means that you should not use any mathematical formula to calculate the first number in the series. Your program must always start looking for an adjacent odd sum
starting with I. If I does not work, start looking for an odd sum that starts with 3, if that does not work start looking at 5, etc.

All fonts must be of size12. Your output should look exactly like the GUI attached.
Format 8 numbers per line for all output exactly as shown.

I have been able to work a part of this problem out, but can't make the whole of it exact.
It's to be done in Visual Basic by the way.
Somebody figure the whole logic.

2. Is this a school assignment or something? That aside, there's not all that much logic to it. Without using any sort of complex algorithm or any formula to figure out the starting number it's a simple nested loop (Pseudo-code as I haven't used VB in awhile and there's no compiler here to check syntax, and the code is nowhere near efficient, i don't know any optimizations for VB):

start_number = 1
counter = start_number
rem store the number your adding to a variable or something here
rem (string = string + "+ " + counter + " ") or something...
rem if the number doesn't match exactly then reset the string
counter = counter + 2
end while
start_number = start_number + 2
end while
The GUI is up to someone else, prefferably you if it's an assignment

3. ummmm invader I would delete the duplicate thread before bitch start bitchin

v_Ln

4. ew sorry, didnt realize the duplicate.
It's not a school project, it's a problem from a textbook.
Thanks anyway

P.S. - i cant delete it damn

5. Haven't looked to see if you figured it out, but I've seen several people mention this lately...if you hit the "edit" button, there is an option on the upper left hand corner that will let you delete your post. If your post is the first post in the thread, it will delete the whole thread...unless JupM changed it.

7. the solution i am providing is in C ... for MS DOS....it works excellent. i dont know VC VC++ to give GUI sol...but some one can port it.

tested with turbo c++ version 3.

Code:
```#include<conio.h>
#include<stdio.h>

main()
{
long sum,no,cube,stoddno,curoddno;

printf("\nEnter the No. ");
scanf("%ld",&no);

cube=no*no*no;

printf("\n%ld*%ld*%ld=%ld=",no,no,no,cube);

stoddno=1;
sum=0;
curoddno=stoddno;

for(;;)
{
sum+=curoddno;

if(sum==cube) break;

else if(sum>cube)
{
sum=0;
stoddno+=2;
curoddno=stoddno;
continue;
}
curoddno+=2;
}

sum=0;

for(;;)
{
printf("%ld",stoddno);
sum+=stoddno;
if(sum==cube) break;
else
{
printf("+");
stoddno+=2;
}
}
}```
executable for the same is attched. rename it to exe n get it working.

8. Thanks debwalin, i know that.
As i said above, if you didnt already read it, "i cant delete it"
Somehow, the button gives me a "Cannot Find Server".

Thanks nulldevice.

9. ****side note, I've been having that problem too with the last thread I created... I wonder if it's a new "bug" or something?****

~AciD

10. What happens if you refresh the page?

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

×