Julia Program to print sum of n natural numbers
Program
function calculateSum(num)
sum = 0
for i in 1:convert(Int64, round(num, digits = 0))
sum = sum + i
end
return sum
end
print("Enter the value of n: ")
n = parse(Int, readline(stdin))
sum = calculateSum(n)
println("Sum of first $n is $sum")
Output
$ julia sum-n-natural-numbers.jl
Enter the value of n: 10
Sum of first 10 is 55