Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- For n=9,
- 0 1 2
- 3 4 5
- 6 7 8
- For n=6,
- Either,
- 0 1 2
- 3 4 5
- or
- 0 1
- 2 3
- 4 5
- int rowlen = (sqrt(n))
- int collen = (n/rowlen)
- int no = 0;
- for (int i = 0; i < rowlen-1) {
- for (int j = 0; j < collen-1) {
- System.out.print(no+"t")
- no++;
- }
- System.out.println()
- }
- var n = 10;
- var cols = 0;
- for(var i=0; i<n; i++) {
- if(i>1 && ((cols === 0 && n%i === 0) || (cols>0 && i%cols===0))) {
- if(cols===0) { // we've found our first prime factor;
- // this value will be used as the number of columns
- cols = i;
- }
- print("n");
- }
- print(i);
- }
Add Comment
Please, Sign In to add comment