Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Who wants to help H-Zence with his homework?!

Author
Message
HZence
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 1st Dec 2003 22:50 Edited at: 1st Dec 2003 22:51
Okay, for you people that are good at math:

Quote: "Write a program that finds the integer from 1 to 1000 with the most divisors that produce NO remainder.

For example, the integer 60 has 12 divisors that produce no remainder: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60."


and...

Quote: "Write a program that will find the least common multiple of two numbers."


FYI this is for a C++ class I'm taking. Basically I'm looking for anything; code samples, ideas, algorithms, etc., would be helpful.

Here's what I have so far for both projects:



LOL. Thanks for the tips...

Team EOD :: Programmer/Storyboard Assistant
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 1st Dec 2003 22:56
Well, the sledgehammer approach would be to have 2 loops, one going from 1 to 1000, other other going from 1 to the first loop. In this inner loop you would do a DIV command, and check to see if there is a remainder. If there isn't, then print this number.


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 1st Dec 2003 22:58
For the second, just start from one and keep going up, checking if it's a multiple to both numbers!

--Mouse: Famous (Avatarless) Fighting Furball

A very nice %it, indeed.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Dec 2003 22:58
Like Nick said, but have an array of 1000 entries that you use to keep count.
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 1st Dec 2003 23:11 Edited at: 2nd Dec 2003 00:32
HZence, for the first one, I would get VERY VERY friendly with the mod command... this is some desk code...(im making this up in my head ergo, its not compiled)


also, your going to need a get_max function in there (I have one but its at my house...Ill send it to you later today.


ok, thats the best i can do with out running the code through a compiler...HZence, check back with me on aim or something and I might be able to run you through and help you out

Amist the Blue Skies...
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 1st Dec 2003 23:14 Edited at: 1st Dec 2003 23:15
just attempted the first 1 in dbp



i think the answers it gives are correct, the first number is the number between 1-1000 then the 2nd is how many divisors it has.
can someone confirm, it would make me proud


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 1st Dec 2003 23:20
oh, btw...I also have a program (completed) that I did that is almost exactlly what your looking for in the second problem...but alas, its at my house...

Amist the Blue Skies...
Shock
AGK Developer
21
Years of Service
User Offline
Joined: 24th Oct 2002
Location: United Kingdom
Posted: 1st Dec 2003 23:20
extermely off topic:

do you actually get to do anything fun in your c++ class?
i was thinking of taking similar lessons myself at college maybe next year (mainly just because i thought it would be kewl to be a c++ pro instead of a c++ n00b, not to be working with the stuff as a career).

The project your are doing now is extremely boring lol.


Sticking feathers up your butt doesn't make you a chicken.
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 1st Dec 2003 23:26 Edited at: 1st Dec 2003 23:28
Quote: "do you actually get to do anything fun in your c++ class?"



na, but this kind of stuff forms the fundementals of programming...if you learn this stuff now, your MUCH better off even with other lauguages...

My teacher likes to call it "Cook Book" code cause it has alot of important applications...

Amist the Blue Skies...
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 1st Dec 2003 23:30
is my attempt any good? although its not in c++ he did ask for anything


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 1st Dec 2003 23:34 Edited at: 1st Dec 2003 23:36
I think it is...however, its wierd...I actually think that Dark Basic (or basic in general) is harder to look at in a glance (most likely due to the fact its almost english)...maybe its just me?

but why did you float the for loop?
Quote: "for t#=1.0 to 1000"


Amist the Blue Skies...
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 1st Dec 2003 23:36
if you don't use floats then it all goes wrong, the answers become 0,0


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 1st Dec 2003 23:43
REALLY? thats not good...they need to fix that...

Amist the Blue Skies...
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 1st Dec 2003 23:46 Edited at: 1st Dec 2003 23:57
i think its because by using floats+integers the float gets rounded so that its a whole number, therefore a remainder will never be detected.
that could be wrong though


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 1st Dec 2003 23:52
Let us know what mark we got you for your homework...


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
HZence
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 2nd Dec 2003 00:26
Lol, well, whoever gave me DBP code thanks but this is C++, lol. (Though I'll probably be able to convert it easily). I haven't had a chance to try these yet because I have to go to work, but when I get home I'll open up VC++ and check it out.

BTW thanks for the help; if anyone has any more suggestions let me know.

Team EOD :: Programmer/Storyboard Assistant
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 2nd Dec 2003 00:41 Edited at: 2nd Dec 2003 00:52
oh, oh! I do...

use this...



Amist the Blue Skies...
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd Dec 2003 00:47
That wont compile...


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 2nd Dec 2003 00:52
Here's my DBPro version (that actually works)




Boo!
TheAbomb12
21
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 2nd Dec 2003 00:56 Edited at: 2nd Dec 2003 00:59
@TCA
...er...what do you mean it won't compile? *cough*


@spooky

that is more or less what I was trying to do, except with 'C'(although, I havent tried to compile mine, so it might be wrong...)

[edit] never mind...mine uses an array and a function to determine a max...

Amist the Blue Skies...

Login to post a reply

Server time is: 2024-09-20 20:13:01
Your offset time is: 2024-09-20 20:13:01