int main() { int n=60; double b; b=n*0.2; if((b-floor(b))==0) print " number is divisible by 5"; else print " number is not divisible by 5"; } this code works fine
________________________________ From: venkatesan B <venkat_b_engin...@yahoo.co.in> To: "algogeeks@googlegroups.com" <algogeeks@googlegroups.com> Sent: Thursday, 5 May 2011 7:12 AM Subject: Re: [algogeeks] Divisibility by five b=n*0.2; if((b-floor(b))==0) print " number is divisible by 5"; else print " number is not divisible by 5"; ________________________________ From: Umer Farooq <the.um...@gmail.com> To: algogeeks@googlegroups.com Sent: Tuesday, 3 May 2011 10:27 AM Subject: Re: [algogeeks] Divisibility by five public static isDivisibleByFive(int input) {String str_input = String.valueof(input); // convert initial int to string. if ((str_input.charat(str_input.length()-1) == '5') || (str_input.charat(str_input.length()-1) == '0') // check if the last character is 0 or 5 .... return true; return false; } u can try something like this ... On Tue, May 3, 2011 at 9:25 AM, Dave <dave_and_da...@juno.com> wrote: Given an integer n, give an O(log n) algorithm to determine if n is >divisible by 5 without using division or mod. > >-- >You received this message because you are subscribed to the Google Groups >"Algorithm Geeks" group. >To post to this group, send email to algogeeks@googlegroups.com. >To unsubscribe from this group, send email to >algogeeks+unsubscr...@googlegroups.com. >For more options, visit this group at >http://groups.google.com/group/algogeeks?hl=en. > > -- Umer -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.