Math, asked by satadru, 4 months ago

Write a program to print the following series:

a. 2, 22, 222, 2222, 22222 in java​

Answers

Answered by Anonymous
1

A simple solution is to compute terms one by one and add to the result.

The above problem can be efficiently solved using the following formula:

Answered by DynamicNinja
2

int num;

System.out.println(“Enter the number of terms: ”);

String tm = input.readLine(); .

num = Integer.parselnt(tm);

int s = 0, c; for (c = 2; c < = num; c+ +){

s = s * 10 + 2;

System.out.print(s + ” “);

} break;

}

}

}

Similar questions