• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Easiest way to find highest number + how to see if one number is divisble by another

Status
Not open for further replies.
Level 2
Joined
Jan 19, 2011
Messages
19
I think GUI is easiest so:
For the first one, set a variable to the amount of numbers you got (the numbers should be in an array)
Set HighestNumber (Real Variable) = Numbers[1]
Loop - 1-AmountVar
If Numbers[IntegerA] is greater than HighestNumber then
set HighestNumber = Numbers[IntegerA]

And the second: Set both into a real variable (if you havent already), then do:
Set X (real) = (Number1/number2)
If X = (convert real (X) into integer) then
set CanBeDivided = true (or something)
Else do
set CanBeDivided = false (or something)

(Havent got Editor on this comp, so I cant test this right now)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
Your computer courses should have taught you these algerthims.

1. is the maximum, where you loop through all elements storing the largest element.
You can also do this by getting the first or last element if the array is sorted, but that is not always possible.

2. Check if the modulous in 0. Even GUI has an instriction for modulus. Basically it returns the remainder of a division opperation, so if the remainder is 0 then the number fully divides the other.
 
Status
Not open for further replies.
Top