Page WAP in JAVA to take a number as input from the user and check whether its divisible by 7 or not.
Answers
Explanation:
Meaning. A formal letter is a letter, written in formal language, in the stipulated format, for official purpose. A letter written in an friendly manner, to someone you are familiar with, is called informal letter. Objective. Professional Communication
Answer:
Given a number, check if it is divisible by 7. You are not allowed to use modulo operator, floating point arithmetic is also not allowed.
A simple method is repeated subtraction. Following is another interesting method.
Divisibility by 7 can be checked by a recursive method. A number of the form 10a + b is divisible by 7 if and only if a – 2b is divisible by 7. In other words, subtract twice the last digit from the number formed by the remaining digits. Continue to do this until a small number.
Example: the number 371: 37 – (2×1) = 37 – 2 = 35; 3 – (2 × 5) = 3 – 10 = -7; thus, since -7 is divisible by 7, 371 is divisible by 7.