Question: Write a method called friendly Numbers that accepts two 4-digit integer parameters n1 and n2. The method will display whether n1 and n2 are

Write a method called friendly Numbers that accepts two 4-digit integer parameters 

Write a method called friendly Numbers that accepts two 4-digit integer parameters n1 and n2. The method will display whether n1 and n2 are friendly number or not. The header of the method is: public static void friendlyNumbers (int n1, int n2) Note that two integers are friendly if the first digit and the last digit of both numbers are the same. For example 3451 and 3981 are friendly numbers because both numbers starts with 3 and ends with 1, but 3450 and 4650 are not.

Step by Step Solution

3.49 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

class GFG Returns sum of all factors of n static int sumofFactorsint n Traversing through ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

6364f3e99b6d4_239888.pdf

180 KBs PDF File

Word file Icon

6364f3e99b6d4_239888.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!