Skip to content
← Back to Community
Number counter broken
Profile icon
CoolGuy27

This is a simple number counter I made in C#, but if you put in a number that is too high, it stops before finishing. Can someone help me?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
samueluzoma
Profile icon
CoolGuy27
Comments
hotnewtop
Profile icon
Coder100

ok, based on what people say,

using System; using System.Collections.Generic; class Program { static void Main (string[] args) { List<int> numbers = new List<int>(); try { Console.WriteLine("What number do you want me to count to?"); int answer = Convert.ToInt32(Console.ReadLine()) + 1; for (int i = 0 ; i < answer; i++) { numbers.Add(i); Console.WriteLine(numbers[i]); } Console.WriteLine(" "); Console.WriteLine($"Succesfully counted to {answer - 1}"); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine(" "); } catch { Console.WriteLine("Number too high"); } } }
Profile icon
Coder100

What do you mean by a number that is too high

Profile icon
badst

@Coder100
Maximum number a int32 can process is 2,147,483,647, hex 0x7FFFFFFF. That's his problem.

Profile icon
Coder100

oh, well, then don't type it that high when you know it can't support it?

@pepelaugh

Profile icon
badst

@Coder100
Yeah, :D
I was just evaluating on his question, "if i enter a number that is too high...". He probably entered a number higher than that.

Profile icon
Coder100

ye, adding a try catch would fix it :D

@pepelaugh

Profile icon
badst

@Coder100
Yep, or an int64.
:D

Profile icon
Coder100

or unsigned long long xd

@pepelaugh

Profile icon
badst

@Coder100

o_o you got me
k I gotta go no more pings! ;)

Profile icon
Coder100

lol

ok bye!!

@pepelaugh

Profile icon
CoolGuy27

@Coder100
if you do per say 10000 in a new tab it only counts to 7 or 8k, but thanks that would be awesome to use.
image
image

Profile icon
CoolGuy27

@Coder100
also can I make this into a method, so that if the user enters too high of a number, we can ask again?

Profile icon
NirvanaMorradi

@Coder100
hi..I need some help for fork my repl..I have apriciate you if u have time to help me

Profile icon
CoolGuy27

@NirvanaMorradi
Hi! How did you even find this post?? To fork this you need to go to https://replit.com/@CoolGuy27/count-to-infinity?v=1 and click fork

Profile icon
NirvanaMorradi

@CoolGuy27
hi,I have your help in another code .. I had a etherum account..I had privatevkey for that account but in the wrong order ...do you have time to help me ,to fork the repl I send u to ,recode that to try to find the correct order of my 64 hex..I know this is very unlikely to find that but I have to try .. because all of my saving in that

Profile icon
NirvanaMorradi

@CoolGuy27
I have very appreciated if you have time to help me

Profile icon
NirvanaMorradi

@CoolGuy27
https://replit.com/@cristinaparker/Scan1MillionEthAddy?v=1

This is the original code..in this code ,every time ,the random privatevkey was generated..but I want to give my 64hex and every time ,shuffle my private key and search in wanted list

Profile icon
Coder100

btw why are you storing these things inside a list?
You appear to be unusing the list.

Profile icon
CoolGuy27

@Coder100
tbh I have no idea. LOL