Java For Loop to iterate 100 64 36 16 4 0 4 16 36 64 100 using a single variable -


I want to write for the loop in the format below, using only one variable e (____) spaces The only things that I want to change are the print of 100 64 36 16 4 4 4 6 36 64 100. I'm not sure that it will need to be repeated after reaching 0.

 For  (_____________________) System.out Print (______________ + ""); Println ();  

That's what I have tried so far. Is there a way to use only one variable and still have to repeat it through the numbers already used?

 for  (int e = 10; e> 0; e - = 2) System.out.print (e * E + ""); Println ();  

Use the fact that e 2 = ( -e) 2 , and stop when e is no more or equal than -10 .


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -