Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How to show a Number Pattern in Java

+2 votes
asked Jan 11, 2020 by jahnavi (190 points)
1

6   2

10  7   3

13  11  8   4

15  14 12  9   5

3 Answers

+1 vote
answered Jan 17, 2020 by Abhinay Sundar (160 points)
hey, to learn some new concepts in programming, first do any programs in python 3. Its simple and easy to learn and understand. Refer the python program for your question@ link below

https://onlinegdb.com/Bks3UdJbU

Then programming in java is as same as programing in c, though they both languages(C and java) vary in some few Syntax. Refer the java program for your question@ link below

https://onlinegdb.com/HJPrs_1-I
0 votes
answered Jan 18, 2020 by Siddhant_7114
NOT THE EXACT CODE BUT YOU CAN TAKE HELP FROM THIS !

import java.util.*;
 
class Main
{
 public static void main(String args[])
 {
 int i,j,n,k=1;
 Scanner sc = new Scanner(System.in);
     System.out.println("Enter the no of lines");
 n=sc.nextInt();
     for(i=1;i<=n;i++)
     {
 k = (i*(i+1))/2;
 for(j=1;j<=i;j++)
 {
 System.out.printf("%3d",k);
 k--;
 
 }
 System.out.println();
     }
 }
}
0 votes
answered Jan 19, 2020 by jahnavi (190 points)
import java.io.*;
import java.util.Scanner;
class Main{
    public static void main (String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arg[][] = new int[n][n];
        int k = 1;
        
        
        for (int c=0; c<n; c++){
         for (int i=0; i<n; i++){
            for (int j=0; j<n; j++){
                if(j==i-c){
                    arg[i][j] = k;
                    k++;
                }
            }
          }
        }
        
        for (int i=0; i<n; i++){
            for (int j=0; j<=i; j++){
                System.out.printf(" %-2d",arg[i][j]);
            }
            System.out.println();
        }
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...