Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# Hw

Featured Replies

Q- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console.
For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5 ! = 120.

Can someone help me in this? :D

@The Hero of Time maybe? 

int numberIn = Convert.ToInt32(Console.ReadLine());
int result = 1;
for(int i = numberIn; i > 0; i--;){
    result = result * i;
}
Console.WriteLine(numberIn + "!=" + result);

That should work i think.

Edited by Shaft

  • Author
14 minutes ago, Shaft said:

int numberIn = Convert.ToInt32(Console.ReadLine());
int result = 1;
for(int i = numberIn; i > 0; i--;){
    result = result * i;
}
Console.WriteLine(numberIn + "!=" + result);

That should work i think.

Thanks appreciate it :) i didn't understand the question thats why

Solution found, Request close

1 hour ago, progamerz said:

Q- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console.
For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5 ! = 120.

Can someone help me in this? :D

@The Hero of Time maybe? 

:???:

You could have Googled that and found a million examples, it's an extremely common question.

Either way you should have been able to figure it out, especially if you're scripter Juan.

Idk how you could not understand that question, it's a fookin for loop bro.

Time to start expanding your brain fam.

Although the for loop method is preferred, it can also be done recursively:

int Factorial(int i)
{
    if (i <= 1)
        return 1;
    return i * Factorial(i - 1);
}

Edited by Explv

  • Author
2 minutes ago, Explv said:

:???:

You could have Googled that and found a million examples, it's an extremely common question.

Either way you should have been able to figure it out, especially if you're scripter Juan.

Idk how you could not understand that question, it's a fookin for loop bro.

Time to start expanding your brain fam

the factorial didn't make sense for me lol, unless i knew the question wanted like if i entered 10, it will multiply it with all number less than 10 lol 

Considering you're a scripter you and u stating the equation in the question you really should have known how to do it...

Also your welcome.

Edited by Shaft

  • Author
13 minutes ago, Shaft said:

Considering you're a scripter you and u stating the equation in the question you really should have known how to do it...

Also your welcome.

17 minutes ago, Prolax said:

Just an easy for loop..

 

If i am "scripter" doesn't mean i am an expert in math, i have done already 4 exercices before this using "for" loop lol

3 minutes ago, progamerz said:

If i am "scripter" doesn't mean i am an expert in math, i have done already 4 exercices before this using "for" loop lol

Should look up what your trying to solve before asking for help

Coulda just googled how to do it on any programming language and you would be able to convert it 

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.