Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def exerciseElaboration(p, n)
- string = ""
- string[0] = p.to_s
- x = 0
- y = 1
- while (x < n)
- string = string + "0"
- x = x + 1
- end
- string = string + p.to_s
- squared = string.to_i ** 2
- string = squared.to_s
- x = 0
- sum = 0
- while (x < string.length)
- sum = sum + string[x].to_i
- x = x + 1
- end
- return sum
- end
Advertisement
Add Comment
Please, Sign In to add comment