- 1

* ** **** ******** **************** I can't solve this problem! the asterisk should be doubled on each line than previous

the asterisk value should be doubled on each line! please help me out.

7th Sep 2016, 2:02 PM
Santhosh Durai
Santhosh Durai - avatar
6 ответов
+ 3
Without using the Math class: int x = 1; for ( int i = 0; i < 5; i++ ) { for ( int j = 0; j < x; j++ ) { Console.Write( "*" ); } x *= 2; Console.WriteLine(); }
7th Sep 2016, 4:28 PM
Liam
Liam - avatar
+ 2
int n = 4; for (int i = 1; i <= Math.Pow(2.0, n); i*=2) { for (int j = 1; j <= i; j++) { Console.Write("*"); } Console.WriteLine(); }
7th Sep 2016, 2:24 PM
Zen
Zen - avatar
+ 2
Or, for less code: int x = 1; for ( int i = 0; i < 5; i++ ) { Console.Write( new string( '*', x ) + "\n" ); x *= 2; }
7th Sep 2016, 4:30 PM
Liam
Liam - avatar
+ 1
can you write manually without inbuilt operations like power
7th Sep 2016, 2:29 PM
Santhosh Durai
Santhosh Durai - avatar
+ 1
thank you liam! you're great
12th Sep 2016, 6:30 AM
Santhosh Durai
Santhosh Durai - avatar
0
for ( int x = 1; x < 17; x *= 2 ) Console.WriteLine( new string ( "*", x ) );
10th Sep 2016, 9:27 PM
Gábor Náray
Gábor Náray - avatar