|
Post by James :) (aka Madcow) on Mar 27, 2008 13:04:11 GMT -5
abletomake - checks if 2nd parameter number is able to make 1st paramter number
leapyear- checks if year entered in 1st parameter is a leapyear
function abletomake(number, divide) dim i# while true if number<0 and divide>0 or number>0 and divide<0 then i#=i#-1 else i#=i#+1 endif if divide*i# = number then return true elseif divide*i# > number and number > divide or divide*i# < number and number < divide then return false endif wend endfunction function leapyear(yearvalue) if abletomake(yearvalue, 4) and not abletomake(yearvalue, 10) then return true else return false endif endfunction if leapyear(2008) then printr "leap year" else printr "Normal year" endif printr abletomake(2008, 4) printr abletomake(2008, -4) printr abletomake(-2008, 4) printr abletomake(-2008, -4)
|
|
|
Post by Nicky Peter Hollyoake on Mar 27, 2008 16:43:45 GMT -5
Function LeapYear(Year) Return Year % 4 = 0 EndFunction
if LeapYear(2004) Then Print"Leap year"
Else
Print"Normal year" Endif
Wanna know how it works, i'll explain. But its pretty simple. And saves all that coding you've done.
|
|
|
Post by Nicky Peter Hollyoake on Mar 27, 2008 18:11:16 GMT -5
Your "AbleToMake" ...
Function AbleToMake(First, Second) Return Second % First = 0 EndFunction
if AbleToMake(100, 400) Then Print"Found!"
Else
Print"Can't find." Endif
|
|
|
Post by Nicky Peter Hollyoake on Apr 18, 2008 7:33:21 GMT -5
Mhm I was looking on Matthew's wiki, and notice he done a "LeapYear" program. Just want him to explain his program.
Don't a leap happen on a century? (eg: 100, 200, 300).
Nicky
|
|
|
Post by matthew on Apr 18, 2008 7:42:07 GMT -5
Look on the following Wikipedia pages, here & here. On one of those pages it gives the definition of a Leap Year as... Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 was not a leap year; the year 2000 was a leap year.
|
|