please somebody can help me out to get Pascal's Triangle by using loops ( probably with nested loop ) !!

Pleeeeeeeeeeeease

Recommended Answers

All 20 Replies

Ok,

I didn't mean that I want the whole code,

I at least asked for help

Could anyone help me start this !!!

We'll help once you demonstrate you'ev done *something* other than just post for help, please give us your pseudo code and the start of what you have.

This is what I did, so far

using System;
public class Project1
{
    public static void Main()
    {

        Console.Write("Enter a positive integr bound : ");

        int n = Convert.ToInt32(Console.ReadLine());

        for (int i = 0; i <= n+1; i++)
        {
            for (int j = 1 ; j <= i; j++)
            {
                Console.Write(j + " ");
                
            }
            Console.WriteLine();


        }
    }
}

and I am so puzzled

OK, well. Research how to do the pascals triangle first. Thats fundemental that you need for your app.

well,

I don't know how to get the ( Factorial )

like i !, j !, (i-j) !

I'm also having trouble as well. This is the code I have so far.

public class Project3
{

    public static void Main()
    {
        int entry;
        int i = 0;
        int j = 0;
        int x = 0;
        int y = 0;
        
        
        
        
        Console.Write("Enter the number of rows : ");

        int n = Convert.ToInt32(Console.ReadLine());

        for (i = 0; i < n; i++)
        {
            for (i = (x - 1); i > 0; i--)  
 	       {  
	           x = x * i;  
            }
            
         Console.WriteLine(x);  
	       } 
            for (j = 0; j <= i; j++)
            {

                for (j = (y - 1); j > 0; j--)
                {
                    y = y * j;
                }
               entry = x / y;
               Console.WriteLine(entry);

All it does so far is just spit out an endless string of zero.

Why this forum is founded,

it looks nobody wants to help. We I asked for not to plagiarize your work guys !!!!

I really want to get help as soos as possible.

URGENT !!!


nordiquefb

Can I contact you by msn,

check your private messages

I dont let anyone talk to me by MSN, its the work of the devil.

Anyway, while Im still not going to write your code for you, think how a factorial works. In fact, the answer is more simple than you think.

your teachers is getting you to use a specific type of coding, deliberately, and I guess I'll have to tell you the name of it, but, it kinda defeats the purpose of your home work..

You need to use a recursive function, eg, one that calls itself.

Im hoping you know what factorials are.
for those who come across this and dont (shame on you), a factorial is the result of taking a number "n" and multiplying it by all of the numbers below it.. eg 4! would be 4*3*2*1 (although theres no point of *1)

so, what you guys need to do is write a function that does that.

The most common way is a recursive function, although you dont *need* to, but, Id still argue you should.

Now you see if you can code it.. Theres 2 really obvious ways.

if you really do know what I asked for, you could save time when you writing that post.

I asked for how could I get that function NOT what factorials are ( Dump!).

Why dont you use Recursion ?
Its easier and more approached to the Matematical Formulae

dude,

I have to use that formula

i !,

j !,

(i-j) !

I need it with FOR LOOP, but I don't know how to start it

by the way,

what's Recrusion

A factorial is a factorial, and Im not a "dude"

(i-j)! could be (10-5)! which is 5! which has a specific value and never changes and I explained to those who didnt know what a factorial was, how to do it.

At the same time its not uncommon to need to do something like i!-j! which would be 10! - 5! and then that also is a fixed value.

if you dont know what recursion means, please check this link

I wasn't talking to you !!


before you talk to people, learn how to respect yourself !


STEP ASIDE !!

commented: I no longer care whether you pass or fail, and fail seems a) likely, and b) deserved. -4

Your post is not going to get you answers, the reminder of what a factorial is should be more than plenty assistance in working out the code to do it. Ranting at people will not endear anyone to help you.

And yes, I do know the code you need, and its very very simple.

I wasn't talking to you !!


before you talk to people, learn how to respect yourself !


STEP ASIDE !!

I, and everyone else too, realize that programming is often very frustrating. But LizR is just trying to tell you how to do that without actually doing your homework for you. And with that response and attitude you are just chopping off your own arm.

If you have to do the assignment with loops, then look in your textbook about loops. The for loop might be the type you should try. Your text book should should you several examples of loops. Yes, anyone here can tell you about them, but it is better that you look them up yourself so that you learn how to do your own research.

>Your post is not going to get you answers
Indeed. mus1010, it's generally wiser to show respect to the people kind enough to reply to you. Keep in mind that in replying, they're showing you a substantial measure of respect simply by not ignoring yet another "I don't know anything, gimme gimme gimme!" thread.

>Why this forum is founded, it looks nobody wants to help.
We prefer to save our help for those willing to work and research our answers rather than expecting the proverbial silver spoon. In my experience, people with your attitude are complete dead weight. They take without giving back, and attack anyone who doesn't bow down before their demands. If you prove that you're willing to put forth some effort, we'll match that with help.

If you are truely at an end, write down the process on paper, of how you would do it by hand by yourself, write down why you did each thing at each stage and what exactly you did..

heres an example - deliberately not the problem you have:

Such as for a times table..

take a number "n"
1 x n = n
2 x n = n * 2
3 x n = n * 3 ..
12 x n - n * 12
done

Hmm I see a pattern when I do that.
I take a number, I increment it by 1, and multiple n by it.
what does that look like its a loop
so if I have a number from 1 to 12, I multiple it by the number I had..

for counter = 1 to 12
output counter x n = n*counter

Hmm, thats codable..

off you go.

now do the same with your problem

LizR - you are by far the most patient and understanding person I've met in a long time. (well basically we have not met but you get the idea . . .) This guy basically trashes you and you still continue to try to help him. You're amazing - besides that I think you live in the forums but that's another topic.


now mus1010

Either you're not reading your textbook or your textbook bites the big tree branch. If you do what LizR suggests and first write it down in pseudocode or plain english that should help you with the logic which is the hardest part believe it or not.

get an apple
decide to eat the apple or not
if not eat the apple then something_else()
if eat the apple then this()

or whatever, just write down what you need. You can post that if you want and we can make sure your logic is correct. Otherwise if your text is really that bad then look for other c# loop tutorials - there is plenty here to help you if you don't understand them at all - in fact there might be more information here than I really want to tell you but hey, I'm forced to be as kind as LizR (you should apologize, she is only trying to help you the best way. If we give you an answer plainly then you won't learn. And don't get frustrated, programming is a series of tough things to do and figure out and if you get frustrated this early and upset it's going to be a rough life for you)

http://csharp.net-tutorials.com/basics/loops/

commented: Quite so, quite so. +21

Thanks Rapture :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.