New course! Every coder should learn Generative AI!
Try a free lesson+ 27
[ ASSIGNMENT: ] Is 'n' Divisible by x AND y?
TASK : Create a methodย isDivisible(n, x, y)ย that checks if a number n is divisible by two numbers x AND y. NOTE : All inputs are positive, non-zero digits! ย ย For Example : ย isDivisible(3, 1, 3)ย -->ย true ย because 3 is divisible by 1 and 3 ย isDivisible(12, 2, 6)ย -->ย true ย ย because 12 is divisible by 2 and 6 ย ย isDivisible(100, 5, 3)ย -->ย false ย ย because 100 is not divisible by 3 ย ย isDivisible(12, 7, 5)ย -->ย false ย because 12 is neither divisible by 7 nor 5 HappyCodings!:-)
35 Answers
+ 21
https://code.sololearn.com/cf2n3WmP7i59/?ref=app
+ 18
nati
๐ Language!! ๐ ๐๐
+ 17
I will give you one more easy task!! ๐๐๐๐๐ค
Thanks a lot everyone for excellent support and participating!! ๐ค
/*
* Here I am doubting between the two
* answers, ๐ค๐
๐๐
* which one to choose for the best โกโ
* ๐๐ค๐๐๐
*/
+ 16
VcC
๐๐๐๐๐ค
+ 16
nati
TASK :
Create a methodย isDivisible(n, x, y)ย that checks if a number n is divisible by two numbers x AND y ?
&&
Make a Code!!
+ 15
nati
We All have solutions like this !! ๐
boolean isDivisible(int n,int x,int y)
{
return n%x == 0 && n%y == 0 ? true : false;
}
but we need creativity in our codes!! ๐๐
+ 15
nati
Okay, just slowly, we all struggle with something โก
That's why we are here, SL allows us to progress, learn and find first-class people and excellent developers! ๐๐๐
I wish you luck and just go forward, we need time for everything! โบ๐
GoodLuck!! ๐ && HappyCodings!! ๐๐ค
+ 15
D_Stark I agree with you ๐
+ 14
Xan
You did a great job!! ๐๐๐๐๐
Thank you so much for listening my suggestion and do a job. ๐๐
I'm really grateful to you! ๐
+ 10
My first java code :)
Updated!
https://code.sololearn.com/cRNeMtEiVLNc/?ref=app
+ 9
๐Hey! Here's mine... ๐๐
Zero is divisible by any number different than zero.
https://code.sololearn.com/cIprMzfx96bK/?ref=app
+ 8
https://code.sololearn.com/cvJWHt9SI3EN/?ref=app
+ 8
https://code.sololearn.com/cB5J8lE2zk1s/?ref=app
+ 8
Danijel Ivanoviฤ i would do most readable ๐ i think Manish Mahla or Xan made a good one ๐๐
+ 7
even better:
isdiv=lambda n,*p:not any(n%a for a in p)
print(isdiv(24,2,3,4),isdiv(6,3,4))