pagegen Posted October 6, 2010 Share Posted October 6, 2010 Hi Guys just need some advice really I would like to know if there is a way I can check if a number is in a times table for example if(3 is in 4 times table){ do bla bla } the result for above will be false as 4 times table does not contain 3 if(12 is in 4 times table){ do bla bla } the above would be true Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/215280-check-if-a-number-is-in-a-times-table/ Share on other sites More sharing options...
Adam Posted October 6, 2010 Share Posted October 6, 2010 You can use the modulus operator: if (3 % 4 == 0) { // 3 is a multiple of 4 } Quote Link to comment https://forums.phpfreaks.com/topic/215280-check-if-a-number-is-in-a-times-table/#findComment-1119545 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.