myspacee Posted October 12, 2009 Share Posted October 12, 2009 Hello to all,for a program that check newspaper pages i must control if number of given fies is divisible by 4Find some rules on Wikipedia and find here some rules, also for number 4The last two digits divisible by 4. 40832: 32 is divisible by 4but i've not idea to code this simple rule,Any math guy can help me ?thank you,m. Link to comment Share on other sites More sharing options...
99ojo Posted October 12, 2009 Share Posted October 12, 2009 (edited) Hello to all, for a program that check newspaper pages i must control if number of given fies is divisible by 4 Find some rules on Wikipedia and find here some rules, also for number 4 The last two digits divisible by 4. 40832: 32 is divisible by 4 but i've not idea to code this simple rule, Any math guy can help me ? thank you, m. Hi, $number = 40832 ; Get the two numbers from the right and perform a modulus operation $var = Mod (StringRight ($number, 2), 4) ;see help for function Mod If $var = 0 Then MsgBox (0,"",$number & " is divisible by 4") Else MsgBox (0,"",$number & " is not divisible by 4") EndIf or $number = 40832 If Mod (StringRight ($number, 2), 4) = 0 Then MsgBox (0,"",$number & " is divisible by 4") Else MsgBox (0,"",$number & " is not divisible by 4") EndIf ;-)) Stefan Edited October 12, 2009 by 99ojo Link to comment Share on other sites More sharing options...
ProgAndy Posted October 12, 2009 Share Posted October 12, 2009 (edited) Just check the whole number, your Computer should be fast enough $Num = InputBox("Insert a number", "Type a page number to check") $Num = Number($Num) ; make number from string $Mod = Mod($Num, 4) ; calculate remainder If $Mod = 0 Then MsgBox(64, 'OK', "Number of pages (" & $Num & ") is divisible by 4. Page count OK") Else MsgBox(16, 'ERROR', "Number of pages (" & $Num & ") is NOT divisible vby 4" & @CRLF & _ "You have to REMOVE " & $Mod & " pages" & @CRLF & _ "OR ADD " & (4-$Mod) & " more page(s)." ) EndIf Edited October 12, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now