0
How to check the Divisiblitiy of a number(with no value in its reminder) in a range from (for example 1 to 10)?
i mean how it's possible to check if a specific number is divisible for all values inside a given range .. For example this condition : if (4269%(To every value in our specified range) == 0 So the number is divisible (with no Reminder) by all values and if it's not divisible even just by one value in the range (it contains Reminder) so the condition fails..
9 Respostas
+ 2
Do you mind sharing your code with us, so that we can help you. Anything that you have tried is appreciated so do not hesitate to share it with us.
+ 2
Check this code
It takes an input from user as a number to check divisiblity.
You can change the first and last number of the range in the code
Contact me if you have any doubts.
https://code.sololearn.com/czx6v5Yua91X/?ref=app
+ 2
Yea that's nice. I made one too.
https://code.sololearn.com/cQ3hwusPeJ1y/?ref=app
+ 2
Hmmmmm.. Cheer 🍻
+ 2
SapiOoOcEcdual
Yeah, that's great man.
+ 1
Akbar Ali
Tnx buddy for the time u dedicated to help me 🌷
But my mean wasn't to check to see to what specific numbers inside a range Users ' defined input is divisible.. Like the one U wrote..
My meant was : suppose weve gotten a number n we wanna check if that number itself is divisible by all the values inside a specific range (ALL ofem) n if it's so, print "it's divisible" n if its not, print "it's not divisible"..
+ 1
Avinesh Akbar Ali
Part 1: ⏬
After i posted this Q it was my scheduled time for exercising n through all of the time which i was training suddenly i got the idea to write the code..
at first i thought about creating an array for storing every counts which the condition turns to be right(pay attention that at tge first step w knew the condition to act on that.. Hadn't any problem on defining the condition itself ) but handling that array to see if its all values is equal to each other was such a kinda sophisticated problem so i sought for another way..
and again suddenly thought about a counter to increments its value every Time the condition proves to be right n bcz i knew how many times the condition is gonna be checked based on the number of the values inside the range so predicted the counter's final value n if it gets to be true so the number is divisible by all the values inside the range..
Yeah I'm so excited bcz this time i solved my problem all by myself n by the help of so-called... ⏬
+ 1
Part 2: ⏬
.. so-called "DivideAndConquer" principle i just read about it recently
never ever Googled anything about it n never ever cheated from anyone else's..
Ohh God such a feeling is so sexy when u solve ur problem by urself 😇
I think I'm progressing
https://code.sololearn.com/czzkKM0BZGvd/?ref=app
+ 1
Avinesh Akbar Ali
Guys i just completed the code n made it more Useful .. Now u can find the largest n the smallest numbers inside ur-Defined range which are divisible by each numbers from 1 to 10..
Plz check it..
Tnx u
https://code.sololearn.com/cp1mPkd9xtPZ/?ref=app