100.upto(3407) do |i|
str=i.to_s
arr=str.split("")
print i
print "\t"
sum=0
sum= arr[arr.length-1]
print sum
print "\t"
sum2=0
sum3=0
sum2=arr.each{|element|
sum3+=element.to_i
}
print sum3
print"\t"
sum4=0
sum4=((sum3.to_i)-(arr[arr.length-1].to_i))
puts sum4
puts "\t"
I know that I need to use an if statement, and I've tried " if sum==sum4" but that wasn't working. any suggestions? thanks :D im a beginner so im still taking this all in

New Topic/Question
Reply




MultiQuote




|