Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A five-digit number is said to be friendly if the leftmost digit is divisible by

ID: 3538503 • Letter: A

Question

A five-digit number is said to be friendly if the leftmost digit is divisible by 1, the leftmost two digits are divisible by 2, the leftmost three digits are divisible by 3, the leftmost four digits are divisible by 4, the leftmost five digits (the number itself) are divisible by 5.


For example the number 42325 is a friendly number (4 is divisible by 1, 42 is divisible by 2, 423 is divisible by 3, 4232 is divisible by 4 and 42325 is divisible by 5).


Write the algorithm (not the program) for a program that would prompt a user to enter a five digit number and then determine and print to the screen if the number entered is friendly or not. You may write your algorithm as a text document or as a flowchart.

Explanation / Answer

step 1: Take the number in an integer array... step2: now take a variable named splitter and intialize it to 0... step3: LOOP: now start a loop with i value to 0 and increment the value of i at the end of every loop... step 4: multiply splitter variable with 10 and add array[i] to it and divide it with [i+1]...(for the first time, splitter will be (0*10)+array[i];.... step 5: go to loop..repeat the same process.... step6: print the result if it is divisible by 1 2 3 4.. step7: otherwise,print not friendly.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote