- 2
R language wap to print the number from 1 to 100 and check that they are divisible by 3 and divisible by 5 and divisible by both
print("generating a numbers by Khushi from 1 to 100 range ") #start=1 #stop=100 #stepsize=1 matlab humare 1 se in increment hoga for i in range (1,100,1) if(i%3==0) { print (the number is divisible by 3) } else if(i %5==0) { print ("the number is divisible by 5") } else { if (i%3&&i%5==0) { print("the number is divisible by both 3 and 5") } } Please check the code and solution provide it
5 Réponses
+ 1
People are more likely to test your code if you put them on sololearn playground instead of pasting it i to the description.
The R range() does not work like the Python range()
First check if the number is divisible by 3 && 5, then if it is divisible by 3 or 5.
+ 1
Yes, it is not working. READ MY PREVIOUS COMMENT.
0
for(x in 1:100){ + if(x%%10==0){ + print(x) + } + }
- 2
print("generating a numbers by Khushi from 1 to 100 range ")
#start=1
#stop=100
#stepsize=1 matlab humare 1 se in increment hoga
for( i in 1:100)
if(i%%3==0)
{
print (i,the number is divisible by 3)
}
else if(i %%5==0)
{
print (i,"the number is divisible by 5")
}
else
{
if (i%%3 & i%%5==0)
{
print( i ,"the number is divisible by both 3 and 5")
}
}
- 2
My code is not working